skywalking icon indicating copy to clipboard operation
skywalking copied to clipboard

[Bug] log4j2 All Loggers Asynchronous report to skywalking does not display traceId

Open it-ll opened this issue 4 years ago • 6 comments

Search before asking

  • [X] I had searched in the issues and found no similar issues.

Apache SkyWalking Component

Java Agent (apache/skywalking-java)

What happened

Use log4j2 to print logs asynchronous(All Loggers Asynchronous), the format is json, and there is no traceId on the web ui

What you expected to happen

UI web displays traceID

How to reproduce

Configure the lo4j2 log as All Loggers Asynchronous, the log format as Json, and the traceId is not displayed on the reported skywalking

Anything else

No response

Are you willing to submit PR?

  • [x] Yes I am willing to submit a PR!

Code of Conduct

it-ll avatar Apr 22 '22 08:04 it-ll

Async writer is not supported, because getTraceId is not in the correct context.

wu-sheng avatar Apr 22 '22 08:04 wu-sheng

Check doc first https://skywalking.apache.org/docs/skywalking-java/v8.10.0/en/setup/service-agent/java-agent/application-toolkit-log4j-2.x/

There are several difference usages.

wu-sheng avatar Apr 22 '22 08:04 wu-sheng

Asynchronous means that it does not support display on the ui?

it-ll avatar Apr 22 '22 08:04 it-ll

Read doc, before asking

wu-sheng avatar Apr 22 '22 08:04 wu-sheng

1、The log print format is configured as PatternLayout charset="UTF-8" pattern="[%d][%t][%p][%c:%L][%X{X-B3-TraceId}] %m%n"/> can print normally traceId 2、The log print format is configured as json <JsonLayout eventEol="true" compact="true"> <KeyValuePair key="timestamp" value="$${date:yyyy-MM-dd HH:mm:ss.SSS}" /> <KeyValuePair key="projectName" value="unm" /> <KeyValuePair key="podName" value="vfr" /> </JsonLayout> can not print normally traceId why?

it-ll avatar Apr 22 '22 10:04 it-ll

1、The log print format is configured as PatternLayout charset="UTF-8" pattern="[%d][%t][%p][%c:%L][%X{X-B3-TraceId}] %m%n"/> can print normally traceId 2、The log print format is configured as json <JsonLayout eventEol="true" compact="true"> <KeyValuePair key="timestamp" value="$${date:yyyy-MM-dd HH:mm:ss.SSS}" /> <KeyValuePair key="projectName" value="unm" /> <KeyValuePair key="podName" value="vfr" /> </JsonLayout> can not print normally traceId why?

me too

sunjiajie avatar Jan 17 '23 06:01 sunjiajie