一、代码调用方式:
 
 public static readonly Logger Logger = LogManager.GetCurrentClassLogger();
        Logger .Trace("trace log message"); 
        Logger .Debug("debug log message"); 
        Logger .Info("info log message"); 
        Logger .Warn("warn log message"); 
        Logger .Error("error log message"); 
        Logger .Fatal("fatal log message"); 
 
 
二、NLog配置文件,NLog.config
 
<?xml version="1.0" encoding="utf-8" ?> 
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">  
<targets> 
<target name="file" xsi:type="File" fileName="${basedir}/Logs/${shortdate}.log" 
layout="${date:format=yyyy-MM-dd HH\:mm\:ss} : ${message}" /> 
</targets>  
<rules> 
<logger name="*" minlevel="Info" writeTo="file" /> 
</rules> 
</nlog> 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-19
  • 2021-07-30
  • 2022-01-20
  • 2021-12-06
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-26
  • 2021-10-28
  • 2022-01-24
  • 2022-12-23
  • 2022-01-20
相关资源
相似解决方案