2014年8月28日 星期四

個人常用Log格式筆記

個人常用的Log格式,在此記錄一下

<?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" autoReload="true">

    <!-- 
  See https://github.com/nlog/nlog/wiki/Configuration-file 
  for information on customizing logging rules and outputs.
   -->
    <targets async="true">
        <default-wrapper xsi:type="BufferingWrapper" bufferSize="500" flushTimeout="3000" />

        <target xsi:type="Chainsaw" name="console" address="udp4://127.0.0.1:7071"
                layout="${longdate} ${uppercase:${level}} ${message}" />

        <target xsi:type="File" name="file" fileName="D:\LogFiles\Proj_Log\${shortdate}\${date:format=yyyy-MM-dd-HH}.log"
                  layout="${longdate} ${uppercase:${level}} ${message}${newline}${onexception:inner=${newline}Exception:${newline}${exception:format=ToString}${newline}}STACKTRACE:${newline}${stacktrace:format=DetailedFlat}" />
    </targets>

    <rules>
        <logger name="*" minlevel="Trace" writeTo="console,file" />
    </rules>
</nlog>