建議 依賴 <package id="Anotar.NLog.Fody" version="3.3.0" targetFramework="net40" developmentDependency="true" /> <package id="Fody" version="2.1.0" target ...
1 public static void InitLog(TargetWithLayout target = null, string level = "Debug", string logger = "*") 2 { 3 4 LoggingConfiguration logConfig = LogManager.Configuration ?? new LoggingConfiguration(); 5 6 if (target == null) target = new ConsoleTarget(); 7 8 if (target.Name == null) target.Name = target.GetType().Name; 9 10 logConfig.AddTarget(target.Name, target); 11 12 logConfig.LoggingRules.Add(new LoggingRule(logger, LogLevel.FromString(level), target)); 13 14 LogManager.Configuration = logConfig; 15 16 }
建議 依賴
<package id="Anotar.NLog.Fody" version="3.3.0" targetFramework="net40" developmentDependency="true" />
<package id="Fody" version="2.1.0" targetFramework="net40" developmentDependency="true" />
<package id="NLog" version="4.4.11" targetFramework="net40" />
<package id="NLog.Windows.Forms" version="4.2.3" targetFramework="net40" />