skywalking icon indicating copy to clipboard operation
skywalking copied to clipboard

[Bug] Log4j2 doesn't print traceid(mutableLogEvent)

Open Chenfx-git opened this issue 3 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

Log4j2 doesn't print traceid. We've seen Log4j2 plugin doesn't enhance mutableLogEvent.

What you expected to happen

Logs can print traceid in all scenarios.

How to reproduce

log4j2: Use async tab print log asynchronously(not log4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector) and ENABLE_THREADLOCALS was true, will use mutableLogEvent.

Anything else

When logEvent is mutableLogEvent , field doesn't containt "_$EnhancedClassField_ws", so it always print traceid "N/A".

Are you willing to submit PR?

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

Code of Conduct

Chenfx-git avatar Mar 30 '23 06:03 Chenfx-git

We don't declare we support mutableLogEvent. AFAIK. I think this should not be an issue.

wu-sheng avatar Mar 30 '23 06:03 wu-sheng

Why is it not supported? I see plugin only support log4jLogEvent and ringBufferLogEvent.

Chenfx-git avatar Mar 30 '23 06:03 Chenfx-git

Why should? This is an open-source community. We don't have any responsibility to support anything.

wu-sheng avatar Mar 30 '23 06:03 wu-sheng

It's simply not implemented, there's no reason on the "why". However, if you would like to support it, we welcome the contribution.

Superskyyy avatar Mar 30 '23 06:03 Superskyyy

I just want to know if there's another reason because log is very important. I can try to support it.

Chenfx-git avatar Mar 30 '23 06:03 Chenfx-git

I just want to know if there's another reason because log is very important. I can try to support it.

Nope, I think its just a missing point, feel free to file a PR to support it.

Superskyyy avatar Mar 30 '23 18:03 Superskyyy