kelunik
(Niklas Keller)
April 24, 2023, 12:07pm
1
If I use async logging, the transaction.id
and trace.id
fields aren't set in the log messages.
System.setProperty("log4j2.contextSelector", "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector");
I'd like to keep using async logging, but still benefit from the trace and transaction correlation. What's the recommended way to do that?
kelunik
(Niklas Keller)
April 26, 2023, 8:15am
2
These seem to be the relevant parts:
https://logging.apache.org/log4j/2.x/manual/extending.html#LogEventFactory
Note: When log4j is configured to have all loggers asynchronous , log events are pre-allocated in a ring buffer and the LogEventFactory is not used.
Elastic instruments the LogEventFactory
, but this factory isn't used if async logging is used.
Yes that's the instrumentation applied for Log4j. I think you're right, I can't see where we would capture async logs. I'll discuss with the team next week but I don't think I have a useful answer for you now
kelunik
(Niklas Keller)
April 26, 2023, 2:15pm
4
@Jack_Shirazi I've now added this to our already existing ContextDataProvider
, see Elastic APM · GitHub
It seems like this might be a good API to use for the agent as well: Log4j – Extending Log4j 2
I haven't anything for error.id
, yet.
1 Like
Thanks for the report and the suggestions, we've opened an issue and hope to get to it next Q
system
(system)
Closed
May 24, 2023, 8:32am
7
This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.