diff --git a/Torch.Server/Program.cs b/Torch.Server/Program.cs index c50b9ff..80ec126 100644 --- a/Torch.Server/Program.cs +++ b/Torch.Server/Program.cs @@ -63,7 +63,8 @@ namespace Torch.Server File.Move(oldTorchCfg, torchCfg, true); Target.Register(nameof(LogViewerTarget)); - LogManager.Configuration = new XmlLoggingConfiguration(newNlog); + TorchLogManager.Configuration = new XmlLoggingConfiguration(newNlog); + LogManager.Configuration = TorchLogManager.Configuration; LogManager.ReconfigExistingLoggers(); var config = Persistent.Load(torchCfg); diff --git a/Torch/Patches/GameAnalyticsPatch.cs b/Torch/Patches/GameAnalyticsPatch.cs index 2a38d91..69dcb7c 100644 --- a/Torch/Patches/GameAnalyticsPatch.cs +++ b/Torch/Patches/GameAnalyticsPatch.cs @@ -5,6 +5,7 @@ using System.Runtime.CompilerServices; using NLog; using NLog.Config; using Torch.Managers.PatchManager; +using Torch.Utils; namespace Torch.Patches { @@ -36,16 +37,14 @@ namespace Torch.Patches _log.Warn("GALogger constructor is unknown. Logging may not function."); return; } - ctx.GetPattern(ctor).Prefixes.Add(typeof(GameAnalyticsPatch).GetMethod(nameof(PatchLogger), - BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public)); + ctx.GetPattern(ctor).AddPrefix(nameof(PatchLogger)); } private static void FixLogging() { _setLogger(null, LogManager.GetLogger("GameAnalytics")); - if (!(LogManager.Configuration is XmlLoggingConfiguration)) - LogManager.Configuration = new XmlLoggingConfiguration(Path.Combine( - Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) ?? Environment.CurrentDirectory, "NLog.config")); + if (LogManager.Configuration is not XmlLoggingConfiguration) + LogManager.Configuration = TorchLogManager.Configuration; } private static bool PatchLogger() diff --git a/Torch/Utils/TorchLogManager.cs b/Torch/Utils/TorchLogManager.cs new file mode 100644 index 0000000..bce4f73 --- /dev/null +++ b/Torch/Utils/TorchLogManager.cs @@ -0,0 +1,8 @@ +using NLog.Config; + +namespace Torch.Utils; + +public static class TorchLogManager +{ + public static LoggingConfiguration Configuration { get; set; } +} \ No newline at end of file