fix: normal logging when using webgl in editor

This commit is contained in:
Jakob Feldmann 2024-04-22 13:35:46 +02:00
parent 4610120329
commit 134c6f8923

View File

@ -1,6 +1,9 @@
using System;
using System.IO;
using log4net;
using log4net.Config;
using log4net.Core;
using UnityEngine;
/// <summary>
/// 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