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
[main] INFO com.test.Test -- SLF4J Version: 2.0.15
[main] INFO com.test.Test -- Logback Version: 1.5.11
[main] ERROR com.test.Test -- Exception Message: Custom Message
com.test.Test$CustomException: Some message
at com.test.Test.main(Test.java:15)
[main] WARN com.test.Test -- Exception Message: Custom Message
com.test.Test$CustomException: Some message
at com.test.Test.main(Test.java:15)
Actual output:
[main] INFO com.test.Test -- SLF4J Version: 2.0.15
[main] INFO com.test.Test -- Logback Version: 1.5.11
[main] ERROR com.test.Test -- Exception Message: {}
com.test.Test$CustomException: Some message
at com.test.Test.main(Test.java:15)
[main] WARN com.test.Test -- Exception Message: {}
com.test.Test$CustomException: Some message
at com.test.Test.main(Test.java:15)
Workaround:
Explicitly calling .toString() on the argument (log.error("Exception Message: {}", ex.toString(), ex)), or adding a bogus extra "" argument (log.error("Exception Message: {}", ex, "", ex)) works as a work around, but causes static analysis tools, including the one in IntelliJ, to warn about it.
The text was updated successfully, but these errors were encountered:
If a
Throwable
type is passed to match the last{}
argument, it is ignored, and the formatted log message will write{}
instead.Example:
Expected output:
Actual output:
Workaround:
Explicitly calling
.toString()
on the argument (log.error("Exception Message: {}", ex.toString(), ex)
), or adding a bogus extra""
argument (log.error("Exception Message: {}", ex, "", ex)
) works as a work around, but causes static analysis tools, including the one in IntelliJ, to warn about it.The text was updated successfully, but these errors were encountered: