NLog使用总结

一、代码调用方式:
 
 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> 

你可能感兴趣的:(log)