How can I log the CorrelationManager.ActivityId
as a separate field?
Here is my current 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>
${activityid} was added in NLog v4.1. https://github.com/nlog/nlog/wiki/Trace-Activity-Id-Layout-Renderer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With