【发布时间】:2014-06-12 09:05:06
【问题描述】:
如何将CorrelationManager.ActivityId 记录为单独的字段?
这是我当前的 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">
<variable name="logDirectory" value="${basedir}/Logs" />
<extensions>
<add assembly="NLog.Mongo"/>
</extensions>
<targets>
<target xsi:type="Mongo"
name="mongoCustom"
includeDefaults="false"
connectionString="mongodb://localhost/FooLogging"
collectionName="authLogs">
<field name="Date" layout="${longdate:universalTime=true}" />
<field name="Level" layout="${level}"/>
<field name="Message" layout="${message}" />
<field name="Logger" layout="${logger}"/>
<field name="Exception" layout="${exception:format=tostring}" />
<field name="ThreadID" layout="${threadid}" />
<field name="ThreadName" layout="${threadname}" />
<field name="ProcessID" layout="${processid}" />
<field name="ProcessName" layout="${processname:fullName=true}" />
<field name="UserName" layout="${windows-identity}" />
</target>
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="mongoCustom" />
</rules>
</nlog>
【问题讨论】: