38 lines
1.0 KiB
C#
38 lines
1.0 KiB
C#
namespace Common.UI.Infrastructure
|
|
{
|
|
using Common.Hardware.SIRT;
|
|
|
|
using NLog;
|
|
using NLog.Config;
|
|
using NLog.Targets;
|
|
|
|
using System;
|
|
|
|
internal class AppHost
|
|
{
|
|
public static SIRTBroadcaster SIRTBroadcaster = new SIRTBroadcaster();
|
|
|
|
public static ILogger CreateNLogger(string name)
|
|
{
|
|
LogManager.Configuration = new LoggingConfiguration();
|
|
LogManager.ThrowConfigExceptions = true;
|
|
LogManager.ThrowExceptions = true;
|
|
LogManager.AutoShutdown = true;
|
|
|
|
LogManager.Configuration.AddTarget(new FileTarget(name)
|
|
{
|
|
CreateDirs = true,
|
|
KeepFileOpen = true,
|
|
FileName = $"${{CurrentDir}}/{name}/{DateTime.Now:yyyy-MM-dd}.txt"
|
|
});
|
|
|
|
LogManager.Configuration.AddRule(LogLevel.Trace, LogLevel.Fatal, name);
|
|
LogManager.LogFactory.ReconfigExistingLoggers(true);
|
|
LogManager.ReconfigExistingLoggers(true);
|
|
|
|
return LogManager.GetLogger(name);
|
|
}
|
|
|
|
}
|
|
}
|