mirror of
https://github.com/BililiveRecorder/BililiveRecorder.git
synced 2024-11-16 11:42:22 +08:00
记录运行日志到文件
This commit is contained in:
parent
7b8c436fd9
commit
3d697e1135
|
@ -17,8 +17,34 @@
|
|||
-->
|
||||
<targets>
|
||||
<target name="WPFLogger" xsi:type="MethodCall" className="BililiveRecorder.WPF.MainWindow, BililiveRecorder.WPF" methodName="AddLog">
|
||||
<parameter layout="[${date:format=HH\:mm\:ss}] ${uppercase:${level}} ${event-properties:item=roomid} ${message} ${exception:format=ToString,StackTrace}" />
|
||||
<parameter layout="[${date:format=HH\:mm\:ss}] ${uppercase:${level}} ${event-properties:item=roomid} ${message} ${exception:format=Message}" />
|
||||
</target>
|
||||
|
||||
<target name="file" xsi:type="File"
|
||||
encoding="utf-8"
|
||||
lineEnding="CRLF"
|
||||
fileName="log.txt"
|
||||
maxArchiveFiles="15"
|
||||
archiveFileName="log_archive.{#}.txt"
|
||||
archiveNumbering="Date"
|
||||
archiveEvery="Day"
|
||||
archiveDateFormat="yyyyMMdd">
|
||||
<layout xsi:type="JsonLayout">
|
||||
<attribute name='time' layout='${longdate}' />
|
||||
<attribute name='level' layout='${level:upperCase=true}'/>
|
||||
<attribute name='logger' layout='${logger}'/>
|
||||
<attribute name='roomid' layout='${event-properties:item=roomid}'/>
|
||||
<attribute name='message' layout='${message}'/>
|
||||
<attribute name='exception' encode='false'>
|
||||
<layout xsi:type='JsonLayout'>
|
||||
<attribute name='type' layout='${exception:format=Type}'/>
|
||||
<attribute name='message' layout='${exception:format=Message}'/>
|
||||
<attribute name='tostring' layout='${exception:format=ToString}'/>
|
||||
</layout>
|
||||
</attribute>
|
||||
</layout>
|
||||
</target>
|
||||
|
||||
<!--
|
||||
add your targets here
|
||||
See https://github.com/nlog/NLog/wiki/Targets for possible targets.
|
||||
|
@ -35,6 +61,7 @@
|
|||
<rules>
|
||||
<!-- add your logging rules here -->
|
||||
<logger name="*" minlevel="Trace" writeTo="WPFLogger"/>
|
||||
<logger name="*" minlevel="Trace" writeTo="file"/>
|
||||
<!--
|
||||
Write all events with minimal level of Debug (So Debug, Info, Warn, Error and Fatal, but not Trace) to "f"
|
||||
<logger name="*" minlevel="Debug" writeTo="f" />
|
||||
|
|
|
@ -7,10 +7,35 @@
|
|||
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log">
|
||||
<targets>
|
||||
<target name="WPFLogger" xsi:type="MethodCall" className="BililiveRecorder.WPF.MainWindow, BililiveRecorder.WPF" methodName="AddLog">
|
||||
<parameter layout="[${date:format=HH\:mm\:ss}] ${uppercase:${level}} ${event-properties:item=roomid} ${message} ${exception:format=ToString,StackTrace}" />
|
||||
<parameter layout="[${date:format=HH\:mm\:ss}] ${uppercase:${level}} ${event-properties:item=roomid} ${message} ${exception:format=Message}" />
|
||||
</target>
|
||||
<target name="file" xsi:type="File"
|
||||
encoding="utf-8"
|
||||
lineEnding="CRLF"
|
||||
fileName="log.txt"
|
||||
maxArchiveFiles="15"
|
||||
archiveFileName="log_archive.{#}.txt"
|
||||
archiveNumbering="Date"
|
||||
archiveEvery="Day"
|
||||
archiveDateFormat="yyyyMMdd">
|
||||
<layout xsi:type="JsonLayout">
|
||||
<attribute name='time' layout='${longdate}' />
|
||||
<attribute name='level' layout='${level:upperCase=true}'/>
|
||||
<attribute name='logger' layout='${logger}'/>
|
||||
<attribute name='roomid' layout='${event-properties:item=roomid}'/>
|
||||
<attribute name='message' layout='${message}'/>
|
||||
<attribute name='exception' encode='false'>
|
||||
<layout xsi:type='JsonLayout'>
|
||||
<attribute name='type' layout='${exception:format=Type}'/>
|
||||
<attribute name='message' layout='${exception:format=Message}'/>
|
||||
<attribute name='tostring' layout='${exception:format=ToString}'/>
|
||||
</layout>
|
||||
</attribute>
|
||||
</layout>
|
||||
</target>
|
||||
</targets>
|
||||
<rules>
|
||||
<logger name="*" minlevel="Info" writeTo="WPFLogger"/>
|
||||
<logger name="*" minlevel="Trace" writeTo="file"/>
|
||||
</rules>
|
||||
</nlog>
|
||||
|
|
Loading…
Reference in New Issue
Block a user