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

Lang, Johannes Johannes.Lang at ipi.ch
Thu Oct 30 11:21:39 CET 2008

Hi Nicolas,
as far as i understand your goal, a RollingFileAppender would do the job.
The following appender is an example of a RollingFileAppender, which does
a Rollover every hour with de defined name-pattern. The rollover-policy is
defined by the time-pattern:
<appender name="RollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
	<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
	<layout class="ch.qos.logback.classic.PatternLayout">
		<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>




	Von: logback-user-bounces at qos.ch [mailto:logback-user-bounces at qos.ch] Im Auftrag von nicolas.giraud at bnf.fr
	Gesendet: Donnerstag, 30. Oktober 2008 11:09
	An: logback-user at qos.ch
	Betreff: [logback-user] Adding a timestamp to a FileAppender file

	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">
	        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
	        <layout class="ch.qos.logback.classic.PatternLayout">
	However the %d pattern is not interpreted, is there a way to do this? Maybe using a RollingFileAppender, but I don't see how.
	Avant d'imprimer, pensez à l'environnement.
	Consider the environment before printing this mail.

More information about the Logback-user mailing list