[logback-user] Adding a timestamp to a FileAppender file
Ralph Goers
ralph.goers at dslextreme.com
Thu Oct 30 15:02:30 CET 2008
I would suggest you create a Jira issue for this. I would suggest the
ability to add a custom pattern resolver to the appender might be what
you want. Before Logback I had written my own logging framework that
supported this. I had considered making this request myself but so far I
am not sure that we actually need it yet. It could look something like:
<appender name="file" class="ch.qos.logback.core.FileAppender">
<File
resolver="com.mycorp.logback.MyPatternResolver">myjob.%{host}.%{datetime}.log</File>
<Append>false</Append>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%msg%n</Pattern>
</layout>
</appender>
The Resolver interface would have a single method that looks like
String resolve(String pattern)
Ralph
nicolas.giraud at bnf.fr wrote:
>
> Thanks for the answer, Hannes.
>
> However a time-based rollover is not what I am looking for. My program
> executes one job at a time. There are several jobs whose duration
> varies from a couple of seconds to several hours. I simply want to
> log the results of a job in a single file, and have the filename
> contain a timestamp.
>
> I will have to do this programmatically obviously, but I'm having
> trouble setting up the file appender programmatically.
>
> Regards,
> Nicolas
>
>
> *Avant d'imprimer, pensez à l'environnement.*
> Consider the environment before printing this mail.
> ------------------------------------------------------------------------
>
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://qos.ch/mailman/listinfo/logback-user
>
More information about the Logback-user
mailing list