rschmitt opened a new issue, #3873:
URL: https://github.com/apache/logging-log4j2/issues/3873

   Due to https://github.com/apache/logging-log4j2/pull/3045, all exception 
messages are prefixed with a newline now:
   
   ```text
   [SIGTSTP] [1] ~/src/logging-log4j2 # rg -txml pattern
   src/main/resources/log4j2.xml
   6:                <pattern>%date{EEE MMM dd HH:mm:ss yyyy zzz}{UTC} [%p] 
(%t) %c: %m %ex%n</pattern>
   ```
   
   ```text
   [0] [1] ~/src/logging-log4j2 # ./run.sh
   Darwin 842f57b044d8 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 19:53:27 
PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6041 arm64
   Log4j 2.24.3:
   Thu Aug 07 17:22:01 2025 UTC [ERROR] (main) org.example.App: Going to call a 
method now
   Thu Aug 07 17:22:01 2025 UTC [ERROR] (main) org.example.App: Got exception 
while calling throwException, how could this have happened 
java.lang.RuntimeException: This is the message passed to the RuntimeException 
ctor
        at org.example.App.throwException(App.java:20)
        at org.example.App.main(App.java:12)
   
   Thu Aug 07 17:22:01 2025 UTC [ERROR] (main) org.example.App: Done calling 
method
   
   Log4j 2.25.0:
   Thu Aug 07 17:22:02 2025 UTC [ERROR] (main) org.example.App: Going to call a 
method now
   Thu Aug 07 17:22:02 2025 UTC [ERROR] (main) org.example.App: Got exception 
while calling throwException, how could this have happened
   java.lang.RuntimeException: This is the message passed to the 
RuntimeException ctor
        at org.example.App.throwException(App.java:20)
        at org.example.App.main(App.java:12)
   
   Thu Aug 07 17:22:02 2025 UTC [ERROR] (main) org.example.App: Done calling 
method
   ```
   
   I don't see a way to reproduce the 2.24.3 style of log messages with the 
[pattern 
layout](https://logging.apache.org/log4j/2.x/manual/pattern-layout.html#converter-exception).
   
   1. Using `%ex{0}` to get the first line doesn't work, because a line 
separator is prepended.
   2. I can't find anything in `ThrowableFormatOptions` that provides the type 
of the exception thrown. A pattern like `%m %ex{short.message}%n` doesn't fully 
reproduce the top line of the stack trace.
   3. Using `%n%ex` to print the rest of the stack trace repeats the first 
line. In other words, there's no way to just print the _frames_ of the stack 
trace.
   
   Since this layout change affects log scans, I'd like it if there were a way 
to specify a pattern that reproduces the pre-2.25 layout for anyone who depends 
on it.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to