You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
logger.error("Hello, {}!", "Problem", new Exception("Oh oh"));
Without the transform plugin, the default parameterized message formatter captures the last argument as a throwable -
if it's the last argument and the previous argument count match the placeholder count.
When processed by the ExtendedThrowablePatternConverter, it is fetched -
from LogEvent.getThrown(), which was previously populated when the LogEvent was created, from Message.getThrowable().
This provides the throwable pattern converter the information to format the throwable as a message/stacktrace.
Here is the code generated by the transform plugin:
It create a LogBuilder, but does not use its .withThrowable(Throwable) method -
leading to a LogEvent that does not have the throwable set.
My thought is that to resolve that, the transform plugin needs - at build time - to analyze the logger call in the same way the logger does to extract the throwable arg and set it using .withThrowable(Throwable).
An alternative (might be simpler) - is to change the DefaultLogBuilder (in log4j-api), so that DefaultLogBuilder.logMessage(Message) changes from
In a simple use case, e.g.:
Without the transform plugin, the default parameterized message formatter captures the last argument as a throwable -
if it's the last argument and the previous argument count match the placeholder count.
When processed by the
ExtendedThrowablePatternConverter
, it is fetched -from
LogEvent.getThrown()
, which was previously populated when the LogEvent was created, fromMessage.getThrowable()
.This provides the throwable pattern converter the information to format the throwable as a message/stacktrace.
Here is the code generated by the transform plugin:
It create a
LogBuilder
, but does not use its.withThrowable(Throwable)
method -leading to a
LogEvent
that does not have the throwable set.My thought is that to resolve that, the transform plugin needs - at build time - to analyze the logger call in the same way the logger does to extract the throwable arg and set it using
.withThrowable(Throwable)
.An alternative (might be simpler) - is to change the
DefaultLogBuilder
(inlog4j-api
), so thatDefaultLogBuilder.logMessage(Message)
changes fromto something like
The text was updated successfully, but these errors were encountered: