forked from signalfx/signalfx-dotnet-tracing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNLog.config
58 lines (54 loc) · 3.57 KB
/
NLog.config
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?xml version="1.0" encoding="utf-8" ?>
<!-- Modified by SignalFx -->
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<!-- For JsonLayout when includeMdlc=true, you do not need to do any additional work to extract the 'trace_id' and 'span_id' values (see: https://github.com/NLog/NLog/wiki/JsonLayout) -->
<!--
Additions to layout: none
-->
<target name="jsonFile-includeMdlc-true" xsi:type="File" fileName="log-NLog46-jsonFile-includeMdlc-true.log">
<layout xsi:type="JsonLayout" includeMdlc="true">
<attribute name="time" layout="${longdate}" />
<attribute name="level" layout="${level:upperCase=true}"/>
<attribute name="message" layout="${message}" />
<attribute name="exception" layout="${exception:format=ToString}" />
</layout>
</target>
<!-- For JsonLayout when includeMdlc=false, you must explicitly extract the 'trace_id' and 'span_id' values using new <attribute> nodes (see: https://github.com/NLog/NLog/wiki/JsonLayout) -->
<!--
Additions to layout:
- <attribute name="trace_id" layout="${mdlc:item=trace_id}"/>
- <attribute name="span_id" layout="${mdlc:item=span_id}"/>
-->
<target name="jsonFile-includeMdlc-false" xsi:type="File" fileName="log-NLog46-jsonFile-includeMdlc-false.log">
<layout xsi:type="JsonLayout" includeMdlc="false">
<attribute name="time" layout="${longdate}" />
<attribute name="level" layout="${level:upperCase=true}"/>
<attribute name="message" layout="${message}" />
<attribute name="exception" layout="${exception:format=ToString}" />
<!-- Manual changes: start -->
<attribute name="trace_id" layout="${mdlc:item=trace_id}"/>
<attribute name="span_id" layout="${mdlc:item=span_id}"/>
<attribute name="service.name" layout="${mdlc:item=service.name}"/>
<attribute name="deployment.environment" layout="${mdlc:item=deployment.environment}"/>
<!-- Manual changes: end -->
</layout>
</target>
<!-- For a custom layout, you must explicitly extract the 'trace_id' and 'span_id' values -->
<!--
Additions to layout: {traceId="${mdlc:item=trace_id}",spanId="${mdlc:item=span_id}",service="${mdlc:item=service.name}",environment="${mdlc:item=deployment.environment}"}
-->
<!--
Parsing this log line with a custom Pipeline that adds Trace/Log correlation can be done with the following Processors:
1. Grok Parser: Set the parsing rules to `log_parser %{date("yyyy-MM-dd HH:mm:ss.SSSS"):time}\|%{word:level}\|%{notSpace:logger}\|\{%{data::keyvalue}}\|%{data:message}`
2. Trace Id Remapper: Set the trace_id attribute to 'trace_id'
-->
<target name="textFile" xsi:type="File" fileName="log-NLog46-textFile.log"
layout="${longdate}|${uppercase:${level}}|${logger}|{traceId="${mdlc:item=trace_id}",spanId="${mdlc:item=span_id}"service="${mdlc:item=service.name}",environment="${mdlc:item=deployment.environment}"}|${message}" />
</targets>
<!-- rules to map from logger name to target -->
<rules>
<logger name="*" minlevel="Trace" writeTo="jsonFile-includeMdlc-true,jsonFile-includeMdlc-false,textFile" />
</rules>
</nlog>