[logback-user] Setting the log file file size with RollingFileAppender does not work

Adriana feminity2001 at yahoo.com
Wed Oct 30 14:44:17 CET 2013


I got it to work. Apparently my code was missing the definition of the
rolling policy. However, the logfile is not archived even when its size
exceeds the specified max. size.
Here is the relevant code snippet:

[...]
fileAppender.setFile("C:\\log\\log.txt");
FixedWindowRollingPolicy fwRollingPolicy = new FixedWindowRollingPolicy();
fwRollingPolicy.setContext(loggerContext);
fwRollingPolicy.setFileNamePattern(""C:\\log\\log-%i.txt.zip");
fwRollingPolicy.setMinIndex(1);
fwRollingPolicy.setMaxIndex(3);
fwRollingPolicy.setParent(fileAppender);
fwRollingPolicy.start();

SizeBasedTriggeringPolicy<ILoggingEvent> triggeringPolicy = new
SizeBasedTriggeringPolicy<ILoggingEvent>();
triggeringPolicy.setMaxFileSize("4KB");
triggeringPolicy.start();

[...]

fileAppender.setRollingPolicy(fwRollingPolicy);
fileAppender.setTriggeringPolicy(triggeringPolicy);
fileAppender.start();

[...]

Any suggestions on this? Thanx 



--
View this message in context: http://logback.10977.n7.nabble.com/Setting-the-log-file-file-size-with-RollingFileAdapter-does-not-work-tp13008p13009.html
Sent from the Users mailing list archive at Nabble.com.


More information about the Logback-user mailing list