The is an alternative to Jersey s Jersey s can be configured to log or not log bodies but it cannot be configured to exclude headers Since headers can include authentication tokens you may not want to log headers or only log those in an allow list The bundle can be configured include exclude request bodies include exclude response bodies allow list of headers include exclude the list of excluded header names the max body size before truncation Through code the bundle can be configured to log using different combinations of slf4j log4j logback with context in MDC or OpenTracing or a Map To turn it on add to the list of registered bundles The bundle registers filters which gather all the arguments to log A logger is passed into the constructor which abstracts over whether the logging uses logback or log4j whether the structured arguments are converted into MDC Markers or a Map The in the example above logs using slf4j with context in MDC lives in the module In order to see the logging in action we ll need to configure a log format that includes mdc and markers test example json5 Next lets turn on all the basic filters and see how they change what gets logged Logging output We can rerun and see the new logs in action Logstash encoder is a Dropwizard It sets up a file appender that logs one json object per log statement The json is formatted by logstash logback encoder and is ready to be parsed by logstash Let s add the logstash file appender to the list of configured appenders test example json5 logstash jsonl snippet JerseyHttpLoggingBundle LoggingFeature LoggingFeature JerseyHttpLoggingBundle @Override public void initialize Bootstrap<HelloWorldConfiguration> bootstrap bootstrap setConfigurationFactoryFactory new JsonConfigurationFactoryFactory<> bootstrap addBundle new EnvironmentConfigBundle bootstrap addBundle new ObjectMapperBundle bootstrap addBundle new ConfigLoggingBundle StructuredArgumentsMDCLogger structuredLogger new StructuredArgumentsMDCLogger bootstrap getObjectMapper bootstrap addBundle new JerseyHttpLoggingBundle structuredLogger StructuredArgumentsMDCLogger var mdcLogger new StructuredArgumentsMDCLogger bootstrap getObjectMapper var logstashLogger new StructuredArgumentsLogstashEncoderLogger Consumer<StructuredArguments> structuredLogger structuredArguments > mdcLogger accept structuredArguments logstashLogger accept structuredArguments bootstrap addBundle new JerseyHttpLoggingBundle structuredLogger JerseyHttpLoggingBundle liftwizard bundle logging http <dependency> <groupId>io liftwizard< groupId> <artifactId>liftwizard bundle logging http< artifactId> < dependency> src test resources test example json5 type console timeZone $ LOGGING_TIMEZONE system logFormat %highlight % 5level %cyan %date HH mm ss SSS %dwTimeZone %gray %file %line %white %thread %blue %marker %magenta %mdc %green %logger %message%n%rootException includeCallerData true IntegrationTest DEBUG 13 21 49 dw 249 io liftwizard servlet logging mdc StructuredArgumentsMDCLogger Response sent <> < response http elapsedNanos 1000000000 request http method GET request http parameters query name Dr IntegrationTest request http path full hello world request http path absolute http localhost 63842 hello world request http client port 63855 request http headers User Agent Jersey 2 25 1 HttpUrlConnection 17 0 2 request http server port 63842 request http client host 127 0 0 1 request resourceClass com example helloworld resources HelloWorldResource request http path template hello world request http server name localhost request http headers Host localhost 63842 response http headers Content Type application json response http contentType application json response http entityType com example helloworld api Saying response http status code 200 request http client address 127 0 0 1 request resourceMethod sayHello response http status phrase OK response http body id 1 content Hello Dr IntegrationTest response http contentLength 59 request http server scheme http response http status status OK response http status family SUCCESSFUL> liftwizard config logging logstash file AppenderFactory src test resources test example json5 logging level DEBUG appenders type console timeZone $ LOGGING_TIMEZONE system logFormat %highlight % 5level %cyan %date HH mm ss SSS %dwTimeZone %gray %file %line %white %thread %blue %marker %magenta %mdc %green %logger %message%n%rootException includeCallerData true type file logstash currentLogFilename logs logstash jsonl archivedLogFilenamePattern logs logstash %d jsonl includeCallerData true encoder includeContext true includeMdc true includeStructuredArguments true includedNonStructuredArguments true includeTags true prettyPrint false logs logstash jsonl