NET之NLOG使用

安装
Install-Package NLog.Config
配置文件

  <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
      autoReload="true"
      throwExceptions="false"
      internalLogLevel="Trace" internalLogToConsole="false" internalLogFile="nlog-internal.log">
  <targets  async="true">
    <target name="logfile" xsi:type="File" fileName="file.txt" />
    <target name="logconsole" xsi:type="Console" />
  </targets>
  <rules>
    <logger name="*" minlevel="Info" writeTo="logconsole,logfile" />
    <logger name="*" minlevel="Debug" writeTo="logconsole" />
    <logger name="*" minlevel="Error" writeTo="logconsole,logfile" />
  </rules>
</nlog>  

使用
public static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();
Logger.Error("Error" + (e.Source as AccordionStyleControl).Tag.ToString());