Reputation: 10757
I'm using Dropwizard with Jersey. I've created a new LoggingFeature
to log request/response pairs. The code that instantiates the LoggingFeature
is:
environment.jersey().register(new LoggingFeature(
kivasLogger, Level.INFO, LoggingFeature.Verbosity.PAYLOAD_TEXT,
null));
Unfortunately, my payloads are large and what's being logged is being appended with ...more...
, which is not acceptable for my requirements. I need to log payloads of any size. Can I just replace the above null
maxEntitySize
with Integer.MAX_VALUE
or will that, also, not allow the max entity size to exceed the internal threshold?
Thanks.
Upvotes: 4
Views: 716
Reputation: 10757
After some digging, I arrived at my solution and thought that I would post here to share with others who are encountering this problem.
I found that the LoggingFeature
class internally uses a DEFAULT_MAX_ENTITY_SIZE
value as the default value of the maxEntitySize
constructor parameter. This default value is set if the parameter is not set in the constructor, which it wasn't in my question above. In the current implementation of LoggingFeature
, the value of DEFAULT_MAX_ENTITY_SIZE
is 8192. The maxEntitySize
parameter can be successfully overridden with a value larger than DEFAULT_MAX_ENTITY_SIZE
. I am currently using a maxEntitySize
value of 1024 * 1024
without any issues, and the ...more...
appendage is no longer present.
Note, however, that extremely large values such as Integer.MAX_VALUE
that I proposed above may not be able to be used without incurring a NegativeArraySizeException
(which happened to me).
So basically, changing my problematic line of code above to:
environment.jersey().register(new LoggingFeature(
kivasLogger, Level.INFO, LoggingFeature.Verbosity.PAYLOAD_TEXT,
1024 * 1024));
worked for me, but lines with overly large values like:
environment.jersey().register(new LoggingFeature(
kivasLogger, Level.INFO, LoggingFeature.Verbosity.PAYLOAD_TEXT,
Integer.MAX_VALUE));
didn't work for me.
Upvotes: 2