hd1
hd1

Reputation: 34677

How to show complete log messages on Spring-boot

Most of the messages I looked at in the history are about disabling certain aspects of the log. I'd like the opposite. I'm seeing lots of messages like:

" DEBUG o.s.w.s.m.m.a.HttpEntityMethodProcessor.traceDebug (91) - Writing [" <rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2. (truncated)...]"

I'd like to see the entire, non-truncated, (in this case) RSS feed. Any idea how I can persuade Spring/Logback/console/maven to do this?

Bonus question -- how would I write a test to verify that the logs are actually not truncated? I don't have them persisted in any way, just on the console. Many thanks!

Upvotes: 5

Views: 8552

Answers (2)

Louis
Louis

Reputation: 185

You could also set the TRACE logging level on the HttpLogging entity like this:

logging.level.org.springframework.web.HttpLogging = TRACE

Upvotes: 2

Roland Weisleder
Roland Weisleder

Reputation: 10531

With DEBUG log level, Spring only logs the truncated data. With TRACE log level, Spring logs the complete data.

You could configure something like

logging.level.org.springframework.web.servlet.mvc.method.annotation.HttpEntityMethodProcessor = TRACE

To test the output written to the log (like System.out), have a look into OutputCapture.

@ExtendWith(OutputCaptureExtension.class)
class OutputCaptureTests {

    @Test
    void testName(CapturedOutput output) {
        System.out.println("Hello World!");
        assertThat(output).contains("World");
    }

}

Upvotes: 6

Related Questions