forked from signalfx/signalfx-dotnet-tracing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog4net.config
83 lines (76 loc) · 4.52 KB
/
log4net.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?xml version="1.0" encoding="utf-8" ?>
<!-- Modified by SignalFx -->
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<!-- For the SerializedLayout from the log4net.Ext.Json NuGet package, you can explicitly extract the 'trace_id' and 'span_id' values using new <member> nodes (see: https://github.com/BrightOpen/log4net.Ext.Json#json-stuff) -->
<!--
Additions to layout:
- <member value='trace_id' />
- <member value='span_id' />
-->
<appender name="jsonFileExplicitPropertiesAppender" type="log4net.Appender.FileAppender" >
<file value="log-log4net-jsonFile-explicitProperties.log" />
<layout type='log4net.Layout.SerializedLayout, log4net.Ext.Json'>
<decorator type='log4net.Layout.Decorators.StandardTypesDecorator, log4net.Ext.Json' />
<default />
<!--explicit default members-->
<remove value='message' />
<!--remove the default preformatted message member-->
<member value='message:messageobject' />
<!--add raw message-->
<member value='order-number' />
<!-- Manual changes: start -->
<member value='trace_id' />
<member value='span_id' />
<member value='service.name' />
<member value='deployment.environment' />
<!-- Manual changes: end -->
</layout>
</appender>
<!-- For the SerializedLayout from the log4net.Ext.Json NuGet package, you can also explicitly extract the 'properties' value, which will automatically emit the `trace_id` and `span_id` values (see: https://github.com/BrightOpen/log4net.Ext.Json#json-stuff) -->
<!--
Additions to layout:
- <member value='properties'/>
-->
<appender name="jsonFileAllPropertiesAppender" type="log4net.Appender.FileAppender" >
<file value="log-log4net-jsonFile-allProperties.log" />
<!-- Set up SerializedLayout as defined here: https://github.com/BrightOpen/log4net.Ext.Json#json-stuff -->
<layout type='log4net.Layout.SerializedLayout, log4net.Ext.Json'>
<decorator type='log4net.Layout.Decorators.StandardTypesDecorator, log4net.Ext.Json' />
<default />
<!--explicit default members-->
<remove value='message' />
<!--remove the default preformatted message member-->
<member value='message:messageobject' />
<!--add raw message-->
<!-- Manual changes: start -->
<member value='properties'/>
<!-- Manual changes: end -->
</layout>
</appender>
<!-- For the default PatternLayout, you must explicitly extract the 'trace_id' and 'span_id' values using the %property{name} syntax (see: https://logging.apache.org/log4net/release/manual/contexts.html) -->
<!--
- Additions to layout: {traceId="%property{trace_id}",spanId="%property{span_id}", service="%property{service.name}", environment="%property{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,SSS"):date} \[%{integer:thread}\] %{word:level} %{notSpace:logger} \{%{data::keyvalue}} - %{data:message}`
2. Trace Id Remapper: Set the trace_id attribute to 'traceId'
-->
<appender name="textFileAppender" type="log4net.Appender.FileAppender">
<file value="log-log4net-textFile.log" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %level %logger {traceId="%property{trace_id}", spanId="%property{span_id}", service="%property{service.name}", environment="%property{deployment.environment}"} - %message%newline" />
</layout>
</appender>
<root>
<level value="INFO" />
<appender-ref ref="jsonFileExplicitPropertiesAppender" />
<appender-ref ref="jsonFileAllPropertiesAppender" />
<appender-ref ref="textFileAppender" />
</root>
</log4net>
</configuration>