question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot configure ShortenedThrowableConverter

See original GitHub issue

My 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:closed
  • Created 4 years ago
  • Comments:13

github_iconTop GitHub Comments

2reactions
philsttrcommented, Sep 7, 2019

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”

0reactions
jasonabcommented, Jul 23, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot configure ShortenedThrowableConverter #348 - GitHub
My apologies for filing such a speculative issue, but I cannot seem to get the ShortenedThrowableConverter to work, and I am wondering if...
Read more >
Customize Logback Configuration for Log Optimization
logstash-logback-encoder includes a very powerful throwableConverter called ShortenedThrowableConverter . It'll be a good idea to customize ...
Read more >
Issues in XML Configuration For Logback - Stack Overflow
I am trying to configure LogstashTcpSocketAppender through logback-spring.xml . And when I add the lines <stackTrace> to the LogstashEncoder ...
Read more >
There is a newer version: 7.2 - Download JAR files
ShortenedThrowableConverter maven / gradle build tool code. ... To use this with a {@link PatternLayout}, you must configure conversionRule * as described ...
Read more >
How to use ShortenedThrowableConverter in net.logstash ...
Best Java code snippets using net.logstash.logback.stacktrace.ShortenedThrowableConverter (Showing top 6 results out of 315).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found