Application-toolkit-log4j-2.x.md 652 字节
Newer Older
wu-sheng's avatar
wu-sheng 已提交
1 2 3
* Dependency the toolkit, such as using maven or gradle
```xml
   <dependency>
4
      <groupId>org.apache.skywalking</groupId>
wu-sheng's avatar
wu-sheng 已提交
5 6 7 8 9 10 11 12 13 14 15 16 17
      <artifactId>apm-toolkit-log4j-2.x</artifactId>
      <version>{project.release.version}</version>
   </dependency>
```

* Config the `[%traceId]` pattern in your log4j2.xml
```xml
   <Appenders>
      <Console name="Console" target="SYSTEM_OUT">
         <PatternLayout pattern="%d [%traceId] %-5p %c{1}:%L - %m%n"/>
      </Console>
   </Appenders>
```
18
* When you use `-javaagent` to active the sky-waking tracer, log4j2 will output **traceId**, if it existed. If the tracer is inactive, the output will be `TID: N/A`.