Cannot configure ShortenedThrowableConverter
See original GitHub issueMy apologies for filing such a speculative issue, but I cannot seem to get the ShortenedThrowableConverter to work, and I am wondering if it is getting overwritten somehow in the configuration. This is using Spring Boot 2.1.5 with Logback 1.2.3 and Logstash 6.1.
My logback.xml is very simple:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<throwableConverter class="net.logstash.logback.stacktrace.ShortenedThrowableConverter">
<maxDepthPerThrowable>30</maxDepthPerThrowable>
<maxLength>2048</maxLength>
<shortenedClassNameLength>20</shortenedClassNameLength>
<!-- generated class names -->
<exclude>\$\$FastClassByCGLIB\$\$</exclude>
<exclude>\$\$EnhancerBySpringCGLIB\$\$</exclude>
<exclude>^sun\.reflect\..*\.invoke</exclude>
<!-- JDK internals -->
<exclude>^com\.sun\.</exclude>
<exclude>^sun\.net\.</exclude>
<!-- dynamic invocation -->
<exclude>^net\.sf\.cglib\.proxy\.MethodProxy\.invoke</exclude>
<exclude>^org\.springframework\.cglib\.</exclude>
<exclude>^org\.springframework\.transaction\.</exclude>
<exclude>^org\.springframework\.validation\.</exclude>
<exclude>^org\.springframework\.app\.</exclude>
<exclude>^org\.springframework\.aop\.</exclude>
<exclude>^java\.lang\.reflect\.Method\.invoke</exclude>
<rootCauseFirst>true</rootCauseFirst>
<inlineHash>true</inlineHash>
</throwableConverter>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
However, none of these exclusions (or any of the configuration) take hold. If I remove the “exclude” tags, I get an error about having no exclusion pattern, so I know that the converter is being instantiated. I do get the error twice for some reason, which makes me wonder if the configuration is getting reset somehow.
I have also tried using the <stackTrace> element under <providers> but this does not change the behavior. Any suggestions would be appreciated!
Issue Analytics
- State:
- Created 4 years ago
- Comments:13
Top GitHub Comments
I just updated the documentation.
I decided against outputting a warning when logging an exception as a structured argument. There might be a legitimate use case for this somewhere, and I didn’t want to have to add a configuration option for “don’t log a warning for exceptions logged as structured arguments or markers”
Thanks, Phil, I appreciate your patience on this.
If I might suggest two things, first adding a note/example in the documentation to mention logging exceptions without using kv structures. Second, and I’m not sure how feasible this is, check for a Throwable type before calling Jackson, and logging a warning that the user is serializing a throwable.
Regardless, appreciate your help on this. Logback has been a great help for us.