You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "aber4mx (via GitHub)" <gi...@apache.org> on 2026/01/02 17:52:37 UTC
[I] Throwable pattern conversion loses Exception details [logging-log4j2]
aber4mx opened a new issue, #4019:
URL: https://github.com/apache/logging-log4j2/issues/4019
## Description
Log4j 2's Pattern Layout allows to log Throwables. Several configuration elements allow to configure how the exception stack trace should be logged (max number of lines, package filtering..).
However the default behavior without advanced configuration should be to print the stacktrace "as is". It is mentionned in the documentation:
`If this mode is employed without any configuration, the output will be identical to the one obtained from Throwable#printStackTrace().`
and it was working as of 2.24.3, but the behavior changed in 2.25.3.
On a standard Exception, the logged stacktrace is the same. However Exceptions can override the `Throwable#toString()` method which is used by `Throwable#printStackTrace()` or they could also override `Throwable#printStackTrace()` directly.
Since 2.25.x, log4j emulates `Throwable#printStackTrace()`, even if there is no advanced paramater that justifies it. By upgrading from 2.24.3 the exceptions logged in our application lose some information and meaning.
Could we stick to use `Throwable#toString()` in the default case ? And in the advanced case where that requires cusomization on the StackTraceElements, rather use `Throwable#toString()` for the message part instead of a hard-coded `"throwable.getClass().getName()" + ": " + throwable.getLocalizedMessage()` ?
I attach a patch with a unit test that is green at 2.24.3 but is red at 2.25.3
## Configuration
**Version:** 2.25.3
**Operating system:** windows 11 / RedHat 9
**JDK:** OpenJDK 17.0.2
## Logs
See reproduction scenario
## Reproduction
The below patch adds a unit test red on 2.25.3, but green on 2.24.3.
The unit test logs a custom exception whose class overrides the toString method
[exception_rendering_test.patch](https://github.com/user-attachments/files/24410476/exception_rendering_test.patch)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Throwable pattern conversion loses Exception details [logging-log4j2]
Posted by "vy (via GitHub)" <gi...@apache.org>.
vy commented on issue #4019:
URL: https://github.com/apache/logging-log4j2/issues/4019#issuecomment-3759200129
@Kimbumsoo99, please feel free to submit a PR — you don't need to be assigned or whatsoever.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Throwable pattern conversion loses Exception details [logging-log4j2]
Posted by "JongminChung (via GitHub)" <gi...@apache.org>.
JongminChung commented on issue #4019:
URL: https://github.com/apache/logging-log4j2/issues/4019#issuecomment-3787738081
Hi, @Kimbumsoo99
I noticed that you mentioned having interest in this issue, so I waited for some time. It seems there hasn’t been much progress yet, so I wanted to check in.
Are you still planning to work on this?
If not, would it be okay for me to take over and work on this issue?
Thanks for your clarification.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Throwable pattern conversion loses Exception details [logging-log4j2]
Posted by "vy (via GitHub)" <gi...@apache.org>.
vy commented on issue #4019:
URL: https://github.com/apache/logging-log4j2/issues/4019#issuecomment-3759296079
Some random thoughts on the matter.
1. `ThrowableStackTraceRenderer` should *ideally* produce an identical output to `Throwable::printStackTrace` (and render `toString` just like the latter)
2. There are users in the wild trying to parse and/or locate a stack trace in a log file generated using Pattern Layout, which is explicitly documented to be *not* used as a structured layout
3. Reporters' complaint in this issue (i.e., _"the information that used to be in my log files is missing post-`2.24.3`"_) is legitimate
@alan0428a, you might want to check this issue out.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Throwable pattern conversion loses Exception details [logging-log4j2]
Posted by "Kimbumsoo99 (via GitHub)" <gi...@apache.org>.
Kimbumsoo99 commented on issue #4019:
URL: https://github.com/apache/logging-log4j2/issues/4019#issuecomment-3741339902
Hi @aber4mx.
Thanks for the test case, It clearly demonstrates the issue.
I'd like to take a look at this and provide a fix. May I be assigned to this?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Throwable pattern conversion loses Exception details [logging-log4j2]
Posted by "vy (via GitHub)" <gi...@apache.org>.
vy closed issue #4019: Throwable pattern conversion loses Exception details
URL: https://github.com/apache/logging-log4j2/issues/4019
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Throwable pattern conversion loses Exception details [logging-log4j2]
Posted by "vy (via GitHub)" <gi...@apache.org>.
vy commented on issue #4019:
URL: https://github.com/apache/logging-log4j2/issues/4019#issuecomment-3977678034
Closing this issue, since it duplicates #3623. I will use the latter to process the resolution.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org