[logback-user] TimeBasedRollingPolicy
Per Jørgen Vigdal
Per.Jorgen.Vigdal at evry.com
Mon Nov 4 13:20:44 CET 2013
Thank you Jan-Olav, but sorry, should have read the documentation first.
I achieve what I want just by adding the file property
<appender name="filesystem" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>log.txt</file>
<encoder>
<pattern>%d %5p [%t] %c{1} - %msg%n</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log-%d{yyyy-MM-dd_HH-mm}.txt.%i</fileNamePattern>
<TimeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>1000MB</maxFileSize>
</TimeBasedFileNamingAndTriggeringPolicy >
</rollingPolicy>
</appender>
PerJ
From: Logback-user [mailto:logback-user-bounces at qos.ch] On Behalf Of Jan-Olav Eide
Sent: 4. november 2013 12:07
To: logback users list
Subject: Re: [logback-user] TimeBasedRollingPolicy
How about :
String activeLogFile = "a file name of your choice";
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
RollingFileAppender<ILoggingEvent> appender = new RollingFileAppender<ILoggingEvent>();
appender.setContext(loggerContext);
appender.setFile(activeLogFile);
String archiveDir = "a directory of your choice"
createIfNeeded(archiveDir);
TimeBasedRollingPolicy<ILoggingEvent> timePolicy = new TimeBasedRollingPolicy<ILoggingEvent>();
timePolicy.setFileNamePattern(archiveDir + patternFor("%d{yyyy-MM-dd,aux}/%d{yyyy-MM-dd-hh}")); // hourly
.....
On 4 November 2013 11:09, Per Jørgen Vigdal <Per.Jorgen.Vigdal at evry.com<mailto:Per.Jorgen.Vigdal at evry.com>> wrote:
Hallo.
Is it possible to configure a TimeBasedRollingPolicy so that the file that it is being logged to does not
have any date in the filename, but the rolled over files has.
Thanks
PerJ
_______________________________________________
Logback-user mailing list
Logback-user at qos.ch<mailto: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/20131104/cbb34f56/attachment.html>
More information about the Logback-user
mailing list