Jersey LoggingFeature without MaxEntitySize

I am using Dropwizard from Jersey. I created a new one LoggingFeature

for logging request / response pairs. The code creates an instanceLoggingFeature

:

environment.jersey().register(new LoggingFeature(
            kivasLogger, Level.INFO, LoggingFeature.Verbosity.PAYLOAD_TEXT,
            null));

      

Unfortunately my payloads are large and what is being logged is added with help ...more...

, which is not acceptable for my requirements. I need to record payload of any size. Can I just replace the above null

maxEntitySize

with Integer.MAX_VALUE

or will this also prevent the max entity size from exceeding the internal threshold?

Thank.

+3


source to share


1 answer


After some digging, I came to my solution and thought I'd post here to share with others who are facing this issue.

I found that the class LoggingFeature

internally uses the value DEFAULT_MAX_ENTITY_SIZE

as the default of the constructor parameter maxEntitySize

. This default is set if the parameter is not set in the constructor, which was not in my question above. In the current implementation, theLoggingFeature

value DEFAULT_MAX_ENTITY_SIZE

is 8192. The parameter maxEntitySize

can be successfully overridden with a value greater than DEFAULT_MAX_ENTITY_SIZE

. I am currently using the value maxEntitySize

1024 * 1024

without any problem and the padding is ...more...

no longer present.

Note, however, that extremely large values ​​such as the Integer.MAX_VALUE

one I suggested above cannot be used without arising NegativeArraySizeException

(which happened to me).

So, basically, changing my problematic line of code above:



environment.jersey().register(new LoggingFeature(
        kivasLogger, Level.INFO, LoggingFeature.Verbosity.PAYLOAD_TEXT,
        1024 * 1024));

      

worked for me, but lines with too large values ​​like:

environment.jersey().register(new LoggingFeature(
        kivasLogger, Level.INFO, LoggingFeature.Verbosity.PAYLOAD_TEXT,
        Integer.MAX_VALUE));

      

didn't work for me.

0


source







All Articles