From 134c6f892319bc1e87a7734bd12cc937d9c8aeab Mon Sep 17 00:00:00 2001 From: Jakob Feldmann Date: Mon, 22 Apr 2024 13:35:46 +0200 Subject: [PATCH] fix: normal logging when using webgl in editor --- Assets/Logging/LogManager.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Assets/Logging/LogManager.cs b/Assets/Logging/LogManager.cs index 3d28f9a..4b0ffb5 100644 --- a/Assets/Logging/LogManager.cs +++ b/Assets/Logging/LogManager.cs @@ -1,6 +1,9 @@ using System; +using System.IO; using log4net; +using log4net.Config; using log4net.Core; +using UnityEngine; /// /// Wraps Log4Net to only be used when not bein in a WebGL environment. @@ -12,7 +15,7 @@ public static class LogManager public static log4net.ILog GetLogger(Type type) { -#if !UNITY_WEBGL +#if !UNITY_WEBGL || UNITY_EDITOR return log4net.LogManager.GetLogger(type); #else return new ConsoleLogger(); @@ -21,13 +24,12 @@ public static class LogManager public static void ConfigureLogging() { -#if !UNITY_WEBGL - log4net.GlobalContext.Properties["LogFileName"] = $"{Application.dataPath}" + +#if !UNITY_WEBGL || UNITY_EDITOR + log4net.GlobalContext.Properties["LogFileName"] = $"{Application.dataPath}" + "\\Logging\\SSOLog"; var fi = new FileInfo($"{Application.dataPath}" + "\\Logging\\Log4NetConfiguration.xml"); - XmlConfigurator.Configure(fi); - Log.Debug("Log4Net configured."); + XmlConfigurator.Configure(fi); #else UnityEngine.Debug.Log("When using WebGL, logging is restricted to the console and unity's built in logger."); #endif