<div dir="ltr">Got bitten by HandlerCollection vs HandlerList, which have different semantics. Works fine with a HandlerCollection. </div><div class="gmail_extra"><br><div class="gmail_quote">On 31 January 2017 at 13:56, Jan-Olav Eide <span dir="ltr"><<a href="mailto:janolaveide@gmail.com" target="_blank">janolaveide@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Well, I cheered a bit too soon...<div><br><div><div>       handlers.addHandler(<wbr>logbackInlinedRequestHandler()<wbr>);</div><div>       handlers.addHandler(<wbr>webappHandler(contextPath(), warURL()));<br></div></div></div><div><br></div><div>This causes no data being available on the InputStream of the servlet inside the webapp. <br></div><div>Reversing the order of the handler registrations causes nothing to be request-logged, Probably for the same reason, the data is consumed by the servlet.</div><div><br></div><div>Should not the logback handler be non-invasive in that it should put the data back on the InputStream, or am I missing something here ? </div><div><br></div><div><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On 25 January 2017 at 09:50, Jan-Olav Eide <span dir="ltr"><<a href="mailto:janolaveide@gmail.com" target="_blank">janolaveide@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">That worked out of the box, thanks a lot four your help. I had missed the fact that the RequestLogImpl was in fact the context. </div><div class="m_4891131459637252882HOEnZb"><div class="m_4891131459637252882h5"><div class="gmail_extra"><br><div class="gmail_quote">On 25 January 2017 at 09:09, Ceki Gülcü <span dir="ltr"><<a href="mailto:ceki@qos.ch" target="_blank">ceki@qos.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
LoggerContext is the context for logback-classic whereas RequestLogImpl<br>
*is* the context for logback-access+Jetty.  You need to set requestLog (of type RequestLogImpl) as the context for components such as RollingFileAppender and TimeBasedRollingPolicy. By the way, all logback components must be started. Otherwise, they will not work.<br>
<br>
As such, here a revised version which should work better. Beware, I have not tested this code and it may still contain some wrinkles. Without further ado here is the code:<br>
<br>
  RequestLogImpl requestLog = new RequestLogImpl(); // implements Context<br>
<br>
        ch.qos.logback.access.PatternL<wbr>ayoutEncoder encoder = new ch.qos.logback.access.PatternL<wbr>ayoutEncoder();<br>
        encoder.setContext(requestLog)<wbr>;<br>
        encoder.setPattern("combined")<wbr>;<br>
        encoder.start(); // // components must be started<br>
<br>
        RollingFileAppender<IAccessEve<wbr>nt> appender = new RollingFileAppender<IAccessEve<wbr>nt>();<br>
        appender.setContext(requestLog<wbr>); // requestLog is the context<span><br>
        appender.setName("REQUESTLOG")<wbr>;<br>
        appender.setFile("/bps/log/req<wbr>uest/myrequest.log");<br></span>
        appender.setEncoder(encoder);<br>
<br>
<br>
        TimeBasedRollingPolicy<IAccess<wbr>Event> timePolicy = new TimeBasedRollingPolicy<IAccess<wbr>Event>();<span><br>
<br>
<br>
timePolicy.setFileNamePattern(<wbr>"/bps/log/archive/request/my_r<wbr>equest_%d{yyyy-MM-dd}_%d{HH_mm<wbr>_ss,aux}.log.zip");<br></span>
        timePolicy.setContext(requestL<wbr>og); // requestLog is the context<span><br>
        timePolicy.setMaxHistory(30);<br>
        timePolicy.setTimeBasedFileNam<wbr>ingAndTriggeringPolicy(new StartupTimeBasedTriggeringPoli<wbr>cy<IAccessEvent>());<br>
        timePolicy.setParent(appender)<wbr>;<br></span>
        timePolicy.start(); // components must be started<br>
<br>
        appender.setRollingPolicy(time<wbr>Policy);<br>
        appender.setTriggeringPolicy(t<wbr>imePolicy);<br>
<br>
        appender.start(); // // components must be started<br>
        requestLog.addAppender(appende<wbr>r);<br>
<br>
Let us know how it goes.<br>
<br>
--<br>
Ceki<br>
<br>
On 1/25/2017 8:20, Jan-Olav Eide wrote:<br>
<br>
[snip]<span><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This does not work (it archives etc, but never any contents in the file) :<br>
<br>
        LoggerContext loggerContext =<br>
LoggerContext.class.cast(Logge<wbr>rFactory.getILoggerFactory());<br>
</blockquote>
<br>
<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>
        RollingFileAppender<IAccessEve<wbr>nt> appender = new<br>
RollingFileAppender<>();<br>
        appender.setName("REQUESTLOG")<wbr>;<br>
        appender.setFile("/bps/log/req<wbr>uest/myrequest.log");<br>
        TimeBasedRollingPolicy<IAccess<wbr>Event> timePolicy = new<br>
TimeBasedRollingPolicy<>();<br>
<br>
timePolicy.setFileNamePattern(<wbr>"/bps/log/archive/request/my_r<wbr>equest_%d{yyyy-MM-dd}_%d{HH_mm<wbr>_ss,aux}.log.zip");<br>
        timePolicy.setContext(loggerCo<wbr>ntext);<br>
        timePolicy.setMaxHistory(30);<br>
        timePolicy.setTimeBasedFileNam<wbr>ingAndTriggeringPolicy(new<br>
StartupTimeBasedTriggeringPoli<wbr>cy<IAccessEvent>());<br>
        timePolicy.setParent(appender)<wbr>;<br>
        appender.setRollingPolicy(time<wbr>Policy);<br>
        appender.setTriggeringPolicy(t<wbr>imePolicy);<br>
        PatternLayoutEncoder encoder = new PatternLayoutEncoder();<br>
        encoder.setPattern("combined")<wbr>;<br>
        appender.setEncoder(encoder);<br>
        RequestLogImpl requestLog = new RequestLogImpl();<br>
        requestLog.addAppender(appende<wbr>r);<br>
<br>
On 24 January 2017 at 22:04, Ceki Gülcü <<a href="mailto:ceki@qos.ch" target="_blank">ceki@qos.ch</a><br></span><span>
<mailto:<a href="mailto:ceki@qos.ch" target="_blank">ceki@qos.ch</a>>> wrote:<br>
<br>
<br>
    Hi Jan-Olav,<br>
<br>
    It's not possible to tell without seeing the code in question. Would<br>
    you want to post it here?<br>
<br>
    --<br>
    Ceki<br>
<br>
    On 1/24/2017 19:43, Jan-Olav Eide wrote:<br>
<br>
    > Well, things worked much better with a logback-access.xml file rather<br>
    > than a programmatic construction of the same configuration. Strange,<br>
    > since the latter code works fine elsewhere.<br>
<br>
<br>
</span></blockquote><div class="m_4891131459637252882m_5713035766007055407HOEnZb"><div class="m_4891131459637252882m_5713035766007055407h5">
______________________________<wbr>_________________<br>
logback-user mailing list<br>
<a href="mailto:logback-user@qos.ch" target="_blank">logback-user@qos.ch</a><br>
<a href="http://mailman.qos.ch/mailman/listinfo/logback-user" rel="noreferrer" target="_blank">http://mailman.qos.ch/mailman/<wbr>listinfo/logback-user</a></div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>