[logback-user] logback-access in an embedded jetty server

Jan-Olav Eide janolaveide at gmail.com
Wed Jan 25 08:20:11 CET 2017


This works :
<configuration debug="true">
    <statusListener
class="ch.qos.logback.core.status.OnConsoleStatusListener" />
    <appender name="REQUESTLOG"
        class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>/bps/log/request/bpayadmin_request.log</file>
        <rollingPolicy
            class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">

<fileNamePattern>/bps/log/archive/request/my_request_%d{yyyy-MM-dd}_%d{HH_mm_ss,aux}.log.zip
            </fileNamePattern>
            <maxHistory>30</maxHistory>
            <TimeBasedFileNamingAndTriggeringPolicy
                class="no.buypass.gen.log.StartupTimeBasedTriggeringPolicy"
/>
        </rollingPolicy>
        <encoder>
            <pattern>combined</pattern>
        </encoder>
    </appender>
    <appender-ref ref="REQUESTLOG" />
</configuration>

This does not work (it archives etc, but never any contents in the file) :

        LoggerContext loggerContext =
LoggerContext.class.cast(LoggerFactory.getILoggerFactory());
        RollingFileAppender<IAccessEvent> appender = new
RollingFileAppender<>();
        appender.setName("REQUESTLOG");
        appender.setFile("/bps/log/request/myrequest.log");
        TimeBasedRollingPolicy<IAccessEvent> timePolicy = new
TimeBasedRollingPolicy<>();

timePolicy.setFileNamePattern("/bps/log/archive/request/my_request_%d{yyyy-MM-dd}_%d{HH_mm_ss,aux}.log.zip");
        timePolicy.setContext(loggerContext);
        timePolicy.setMaxHistory(30);
        timePolicy.setTimeBasedFileNamingAndTriggeringPolicy(new
StartupTimeBasedTriggeringPolicy<IAccessEvent>());
        timePolicy.setParent(appender);
        appender.setRollingPolicy(timePolicy);
        appender.setTriggeringPolicy(timePolicy);
        PatternLayoutEncoder encoder = new PatternLayoutEncoder();
        encoder.setPattern("combined");
        appender.setEncoder(encoder);
        RequestLogImpl requestLog = new RequestLogImpl();
        requestLog.addAppender(appender);

On 24 January 2017 at 22:04, Ceki Gülcü <ceki at qos.ch> wrote:

>
> Hi Jan-Olav,
>
> It's not possible to tell without seeing the code in question. Would you
> want to post it here?
>
> --
> Ceki
>
> On 1/24/2017 19:43, Jan-Olav Eide wrote:
>
> > Well, things worked much better with a logback-access.xml file rather
> > than a programmatic construction of the same configuration. Strange,
> > since the latter code works fine elsewhere.
>
>
> _______________________________________________
> logback-user mailing list
> logback-user at qos.ch
> http://mailman.qos.ch/mailman/listinfo/logback-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20170125/e0ad0b02/attachment-0001.html>


More information about the logback-user mailing list