Storing Correlation Id in nlog
durnasaban opened this issue · comments
Şaban Durna commented
Hello,
How can I store the correlation id in nlog logs? Especially which keyword will provide to store correlation id in log sentences (below)?
<targets async="true">
<target
xsi:type="Trace"
name="trace"
layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message:truncate=250} ${exception:format=tostring}"/>
</targets>
Thank you
Lazaretty commented
Hello,
- Set option
AddToLoggingScope = true
in ConfigureServices
services.AddDefaultCorrelationId(options => options.AddToLoggingScope = true);
- To get correlationId in layout use
${mdlc:CorrelationId}