Search code examples
javakotlinloggingjerseydropwizard

Issue with LoggingFeature not logging the complete response body


I'm currently working building an endpoint that will make a couple of requests to an external API. In this endpoint I'm logging all of the request bodies to the terminal. But I'm having an issue where jerseys LoggingFeature doesn't log the complete response body for a request that is done. The log gets cut in the middle of the body. I've tried messing around with the logger level, verbosity but that did nothing. I tried changing maxEntitySize to be a large value but that doesn't change anything either, I'm not really sure what the issue is and why it won't log the complete response body. I've also tried logging to a file instead of the terminal but unfortunately I got the same result.

Here's what the log looks like (as it's proprietary software I had to change some information)

INFO  [2022-10-06 13:54:04,261] se.bla.bla.bla.clients.BlaClientImpl: 1 * Sending client request on thread dw-18 - GET /api/bla/log/98014384
1 > GET https://url.com/2574339575
1 > Accept: application/json
1 > Authorization: Bearer tokenstuff

INFO  [2022-10-06 13:54:04,475] se.bla.bla.bla.clients.BlaClientImpl: 1 * Client response received on thread dw-18 - GET /api/bla/log/98014384
1 < 200
1 < Cache-Control: no-cache
1 < Content-Type: application/json; charset=utf-8
1 < Date: Thu, 06 Oct 2022 13:54:04 GMT
1 < Etag: Yee
1 < Server-Response-Time: 169.44395400000002
1 < Transfer-Encoding: chunked
1 < Vary: Origin
1 < X-Request-Id: Woo
1 < X-Runtime: 0.169337
{example1: "2134123123",example2: "2134123123",example3: "2134123123",example4: "2134123123",example5: "2134123123",example6: "2134123123",example7: "2134123123",example8: "2134123123",example9: "2134123123",example10: "2134123123",example11: "2134123123",example12: "2134123123",example13: "2134123123",example14: "2134123123",example15: "2134123123",example16: "2134123123",example17: "2134123123",example18: "21341

And I've registered the logger like so.

        val restlog = getLogger(BlaClientImpl::class.java.name)
        restlog.addHandler(FileHandler("rest.log", 83886080, 1))
        val requestBuilder =
            client
                .register(
                    LoggingFeature(
                        restlog,
                        Level.INFO,
                        LoggingFeature.Verbosity.PAYLOAD_ANY,
                        83886080
                    )
                )

I'm quite new to the Kotlin/Java world so maybe I'm missing something fundamental.


Solution

  • The issue was a settings with Dropwizard/Jersey. Apparently I had to set gzipEnabled = true