Search code examples
spring-bootlogginglogback

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!


Solution

  • 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");
        }
    
    }