[logback-user] Logback-access pollutes logs with binary file content

Gediminas Rimša gediminas.rimsa at gmail.com
Mon Sep 21 12:04:57 CEST 2020


We have a Spring boot app exposing a RESTful API that runs on embedded
Tomcat (latest versions) and uses logback-access (also latest 1.2.3).

Recently I noticed that access logs include raw binary content of
images/PDF files.

Example from logs:

> POST /projects/projectId/images HTTP/1.1 | status code: 200 | elapsed
time: 664 | request: GIF89a� d �[[ most content ommitted ]]g��� w���� ; |
response: {"id":"877f2338-293d-403b-99fb-09fc631ce7b3"}
> GET /projects/projectid/images/877f2338-293d-403b-99fb-09fc631ce7b3
HTTP/1.1 | status code: 200 | elapsed time: 538 | request:  | response:

What's the best way to configure suppression of request and response bodies
(preferably based on content type)?

Looking at the code, image content suppression happens in
`ch.qos.logback.access.spi.AccessEvent#getResponseContent`, but it only
checks if content type starts with `image/`. I also do not see any code for
binary content suppression in

I traced response image content suppression was added with this commit:
(all the way back in 2007).

Our config:

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
            <evaluator class="ch.qos.logback.access.net.URLEvaluator">
            <pattern>%requestURL | status code: %statusCode | elapsed
time: %elapsedTime | request: %magenta(%requestContent) | response:
    <appender-ref ref="STDOUT"/>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20200921/0fac2b79/attachment.html>

More information about the logback-user mailing list