[logback-user] Adding a timestamp to a FileAppender file

nicolas.giraud at bnf.fr nicolas.giraud at bnf.fr
Thu Oct 30 11:08:57 CET 2008


Hi,

I have just switched from log4j to logback. I would like to generate log 
containing results output by my program, and I want the file name to be 
SomePrefix.<timestamp>.someExt. I can do this programmatically but I'd 
like, if possible, to have all my logging configuration in my logback.xml 
file. Here's the appender I declared :

<appender name="resultFile" class="ch.qos.logback.core.FileAppender">
        <file>${logFolder}/SomePrefix.%d.someExt</file>
        <append>false</append>
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>info</level>
        </filter>
        <layout class="ch.qos.logback.classic.PatternLayout">
            <pattern>%m%n</pattern>
        </layout>
    </appender> 

However the %d pattern is not interpreted, is there a way to do this? 
Maybe using a RollingFileAppender, but I don't see how.

Regards,
Nicolas



Avant d'imprimer, pensez à l'environnement. 
Consider the environment before printing this mail.   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://qos.ch/pipermail/logback-user/attachments/20081030/d32de030/attachment.htm 


More information about the Logback-user mailing list