<div dir="ltr"><div>Hello.</div><div><br></div><div></div><div>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).</div><div><br></div><div>Recently I noticed that access logs include raw binary content of images/PDF files.<br></div><div><br></div><div>Example from logs:</div><div><br></div><div>> 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"}</div>> GET /projects/projectid/images/877f2338-293d-403b-99fb-09fc631ce7b3 HTTP/1.1 | status code: 200 | elapsed time: 538 | request: | response: [IMAGE CONTENTS SUPPRESSED]<div><br></div><div>
<div>What's the best way to configure suppression of request and response bodies (preferably based on content type)?<br></div><div><br></div><div>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 `ch.qos.logback.access.spi.AccessEvent#getRequestContent`.</div><div><br></div><div>I traced response image content suppression was added with this commit: <a href="https://github.com/qos-ch/logback/commit/69290e182f8db6589eadd5a3c485a37255384893">https://github.com/qos-ch/logback/commit/69290e182f8db6589eadd5a3c485a37255384893</a> (all the way back in 2007).<br></div>
</div><div><br></div><div>Our config:</div><div><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"Consolas",monospace"><span style="background-color:rgb(239,239,239)"><</span><span style="color:rgb(0,0,128);background-color:rgb(239,239,239);font-weight:bold">configuration</span><span style="background-color:rgb(239,239,239)">></span><br> <span style="background-color:rgb(239,239,239)"><</span><span style="color:rgb(0,0,128);background-color:rgb(239,239,239);font-weight:bold">appender </span><span style="color:rgb(0,0,255);background-color:rgb(239,239,239);font-weight:bold">name</span><span style="color:rgb(0,128,0);background-color:rgb(239,239,239);font-weight:bold">="STDOUT" </span><span style="color:rgb(0,0,255);background-color:rgb(239,239,239);font-weight:bold">class</span><span style="color:rgb(0,128,0);background-color:rgb(239,239,239);font-weight:bold">="ch.qos.logback.core.ConsoleAppender"</span><span style="background-color:rgb(239,239,239)">></span><br> <span style="background-color:rgb(239,239,239)"><</span><span style="color:rgb(0,0,128);background-color:rgb(239,239,239);font-weight:bold">filter </span><span style="color:rgb(0,0,255);background-color:rgb(239,239,239);font-weight:bold">class</span><span style="color:rgb(0,128,0);background-color:rgb(239,239,239);font-weight:bold">="ch.qos.logback.core.filter.EvaluatorFilter"</span><span style="background-color:rgb(239,239,239)">></span><br> <span style="background-color:rgb(239,239,239)"><</span><span style="color:rgb(0,0,128);background-color:rgb(239,239,239);font-weight:bold">evaluator </span><span style="color:rgb(0,0,255);background-color:rgb(239,239,239);font-weight:bold">class</span><span style="color:rgb(0,128,0);background-color:rgb(239,239,239);font-weight:bold">="ch.qos.logback.access.net.URLEvaluator"</span><span style="background-color:rgb(239,239,239)">></span><br> <span style="background-color:rgb(239,239,239)"><</span><span style="color:rgb(0,0,128);background-color:rgb(239,239,239);font-weight:bold">URL</span><span style="background-color:rgb(239,239,239)">></span>/ping<span style="background-color:rgb(239,239,239)"></</span><span style="color:rgb(0,0,128);background-color:rgb(239,239,239);font-weight:bold">URL</span><span style="background-color:rgb(239,239,239)">></span><br> <span style="background-color:rgb(239,239,239)"></</span><span style="color:rgb(0,0,128);background-color:rgb(239,239,239);font-weight:bold">evaluator</span><span style="background-color:rgb(239,239,239)">></span><br> <span style="background-color:rgb(239,239,239)"><</span><span style="color:rgb(0,0,128);background-color:rgb(239,239,239);font-weight:bold">OnMismatch</span><span style="background-color:rgb(239,239,239)">></span>NEUTRAL<span style="background-color:rgb(239,239,239)"></</span><span style="color:rgb(0,0,128);background-color:rgb(239,239,239);font-weight:bold">OnMismatch</span><span style="background-color:rgb(239,239,239)">></span><br> <span style="background-color:rgb(239,239,239)"><</span><span style="color:rgb(0,0,128);background-color:rgb(239,239,239);font-weight:bold">OnMatch</span><span style="background-color:rgb(239,239,239)">></span>DENY<span style="background-color:rgb(239,239,239)"></</span><span style="color:rgb(0,0,128);background-color:rgb(239,239,239);font-weight:bold">OnMatch</span><span style="background-color:rgb(239,239,239)">></span><br> <span style="background-color:rgb(239,239,239)"></</span><span style="color:rgb(0,0,128);background-color:rgb(239,239,239);font-weight:bold">filter</span><span style="background-color:rgb(239,239,239)">></span><br> <span style="background-color:rgb(239,239,239)"><</span><span style="color:rgb(0,0,128);background-color:rgb(239,239,239);font-weight:bold">encoder</span><span style="background-color:rgb(239,239,239)">></span><br> <span style="background-color:rgb(239,239,239)"><</span><span style="color:rgb(0,0,128);background-color:rgb(239,239,239);font-weight:bold">pattern</span><span style="background-color:rgb(239,239,239)">></span>%requestURL | status code: %statusCode | elapsed time: %elapsedTime | request: %magenta(%requestContent) | response: %cyan(%responseContent)<span style="background-color:rgb(239,239,239)"></</span><span style="color:rgb(0,0,128);background-color:rgb(239,239,239);font-weight:bold">pattern</span><span style="background-color:rgb(239,239,239)">></span><br> <span style="background-color:rgb(239,239,239)"></</span><span style="color:rgb(0,0,128);background-color:rgb(239,239,239);font-weight:bold">encoder</span><span style="background-color:rgb(239,239,239)">></span><br> <span style="background-color:rgb(239,239,239)"></</span><span style="color:rgb(0,0,128);background-color:rgb(239,239,239);font-weight:bold">appender</span><span style="background-color:rgb(239,239,239)">></span><br> <span style="background-color:rgb(239,239,239)"><</span><span style="color:rgb(0,0,128);background-color:rgb(239,239,239);font-weight:bold">appender-ref </span><span style="color:rgb(0,0,255);background-color:rgb(239,239,239);font-weight:bold">ref</span><span style="color:rgb(0,128,0);background-color:rgb(239,239,239);font-weight:bold">="STDOUT"</span><span style="background-color:rgb(239,239,239)">/></span><br><span style="background-color:rgb(239,239,239)"></</span><span style="color:rgb(0,0,128);background-color:rgb(239,239,239);font-weight:bold">configuration</span><span style="background-color:rgb(239,239,239)">></span></pre></div><div><br></div><div>Thanks,</div><div>Gediminas<br></div></div>