File not rolling over with SizeBasedTriggeringPolicy

Hi My log files are not rolling over with the following appender and they grow indefinitely in size: <appender class="ch.qos.logback.core.rolling.RollingFileAppender" name="R"> <File>${catalina.home}/logs/rp.log</File> <Append>true</Append> <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> <level>debug</level> </filter> <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> <FileNamePattern>rp.%i.log.gz</FileNamePattern> <MinIndex>1</MinIndex> <MaxIndex>3</MaxIndex> </rollingPolicy> <TriggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> <MaxFileSize>5MB</MaxFileSize> </TriggeringPolicy> <layout class="ch.qos.logback.classic.PatternLayout"> <Pattern>%-30(%d{HH:mm:ss.SSS} [%thread]) %-5level %logger{64} - %msg %n</Pattern> </layout> </appender> At some point this appender was working correctly so I'm a bit baffled - any suggestions for debugging why it's not working would be appreciated. Thanks Gianni PS. Not sure if this is relevant but I've been upgrading logback as new versions have been released but I couldn't say if it stopped working with a particular release or not.

A bit more information - according to the logs my configuration seems ok, any ideas why the triggering policy is not working? 08:22:58,004 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml] 08:22:58,005 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/usr/local/apache-tomcat6.0/ webapps/resprompt/WEB-INF/classes/logback.xml] 08:22:58,072 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender] 08:22:58,081 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [R] 08:22:58,110 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Pushing component [filter] on top of the object stack. 08:22:58,119 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Pushing component [rollingPolicy] on top of the object stack. 08:22:58,124 |-INFO in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@6f5ab27a - Adding parent to RollingPolicy: R 08:22:58,148 |-INFO in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@6f5ab27a - Will use gz compression 08:22:58,151 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Pushing component [TriggeringPolicy] on top of the object stack. 08:22:58,201 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[R] - Active log file name: /usr/local/apache-tomcat6.0/logs/rp.log 08:22:58,201 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[R] - File property is set to [/usr/local/apache-tomcat6.0/logs/rp.log] 08:22:58,203 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Popping appender named [R] from the object stack 08:22:58,203 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender] 08:22:58,203 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [WicketRequest] 08:22:58,203 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Pushing component [filter] on top of the object stack. 08:22:58,203 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Pushing component [rollingPolicy] on top of the object stack. 08:22:58,204 |-INFO in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@2b7ba0b3 - Adding parent to RollingPolicy: WicketRequest 08:22:58,204 |-INFO in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@2b7ba0b3 - Will use gz compression 08:22:58,204 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Pushing component [triggeringPolicy] on top of the object stack. 08:22:58,205 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[WicketRequest] - Active log file name: /usr/local/apache-tomcat6.0/logs/wicketRequest.log 08:22:58,205 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[WicketRequest] - File property is set to [/usr/local/apache-tomcat6.0/logs/wicketRequest.log] 08:22:58,205 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Popping appender named [WicketRequest] from the object stack 08:22:58,205 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender] 08:22:58,206 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT] 08:22:58,207 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Popping appender named [STDOUT] from the object stack 08:22:58,207 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.classic.net.SMTPAppender] 08:22:58,269 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [EMAIL] 08:22:58,333 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Popping appender named [EMAIL] from the object stack 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.springframework] to true 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - org.springframework level set to DEBUG 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.hibernate.cache] to true 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - org.hibernate.cache level set to DEBUG 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [com.resprompt] to true 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - com.resprompt level set to DEBUG 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [com.sun.facelets] to true 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - com.sun.facelets level set to DEBUG 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.springframework.orm] to true 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - org.springframework.orm level set to INFO 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.hibernate.SQL] to true 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - org.hibernate.SQL level set to DEBUG 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.hibernate.transaction] to true 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - org.hibernate.transaction level set to DEBUG 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.hibernate] to true 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - org.hibernate level set to INFO 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.hibernate.tool.hbm2ddl] to true 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - org.hibernate.tool.hbm2ddl level set to DEBUG 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.directwebremoting] to true 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - org.directwebremoting level set to INFO 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.springframework.transaction] to true 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - org.springframework.transaction level set to INFO 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.springmodules.cache] to true 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - org.springmodules.cache level set to DEBUG 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.apache.commons.digester] to true 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - org.apache.commons.digester level set to INFO 08:22:58,334 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.apache.wicket.protocol.http.RequestLogger] to false 08:22:58,334 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [WicketRequest] to Logger[org.apache.wicket.protocol.http.RequestLogger] 08:22:58,335 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - root level set to DEBUG 08:22:58,335 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [EMAIL] to Logger[root] 08:22:58,336 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [R] to Logger[root] 08:22:58,336 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration. Thanks Gianni On 15/gen/09, at 07:41, Gianni Doe wrote:
Hi My log files are not rolling over with the following appender and they grow indefinitely in size:
<appender class="ch.qos.logback.core.rolling.RollingFileAppender" name="R"> <File>${catalina.home}/logs/rp.log</File> <Append>true</Append> <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> <level>debug</level> </filter> <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> <FileNamePattern>rp.%i.log.gz</FileNamePattern> <MinIndex>1</MinIndex> <MaxIndex>3</MaxIndex> </rollingPolicy> <TriggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> <MaxFileSize>5MB</MaxFileSize> </TriggeringPolicy> <layout class="ch.qos.logback.classic.PatternLayout"> <Pattern>%-30(%d{HH:mm:ss.SSS} [%thread]) %-5level %logger{64} - %msg %n</Pattern> </layout> </appender>
At some point this appender was working correctly so I'm a bit baffled - any suggestions for debugging why it's not working would be appreciated. Thanks Gianni
PS. Not sure if this is relevant but I've been upgrading logback as new versions have been released but I couldn't say if it stopped working with a particular release or not.
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://qos.ch/mailman/listinfo/logback-user

Hello Gianni, I have opened a jira issue regarding this problem. Its url is http://jira.qos.ch/browse/LBCLASSIC-105 Looking at the configuration file, the File property reads "${catalina.home}/logs/rp.log" while the FileNamePattern property is set to "rp.%i.log.gz". This means that the archived files will be located in current folder. If you wish to have the archived files located next to the current log file, you need to set FileNamePattern property to "${catalina.home}/logs/rp.%i.log.gz" I have tested your configuration file, and it seems to work just fine. If there are indeed problems with the roll over, they should be visible by printing logback's internal status. Here is code that does that: LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); StatusPrinter.print(lc); Invoke it after roll over occurs or at application exit. Gianni Doe wrote:
A bit more information - according to the logs my configuration seems ok, any ideas why the triggering policy is not working?
08:22:58,004 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml] 08:22:58,005 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/usr/local/apache-tomcat6.0/ webapps/resprompt/WEB-INF/classes/logback.xml] 08:22:58,072 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender] 08:22:58,081 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [R] 08:22:58,110 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Pushing component [filter] on top of the object stack. 08:22:58,119 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Pushing component [rollingPolicy] on top of the object stack. 08:22:58,124 |-INFO in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@6f5ab27a - Adding parent to RollingPolicy: R 08:22:58,148 |-INFO in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@6f5ab27a - Will use gz compression 08:22:58,151 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Pushing component [TriggeringPolicy] on top of the object stack. 08:22:58,201 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[R] - Active log file name: /usr/local/apache-tomcat6.0/logs/rp.log 08:22:58,201 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[R] - File property is set to [/usr/local/apache-tomcat6.0/logs/rp.log] 08:22:58,203 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Popping appender named [R] from the object stack 08:22:58,203 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender] 08:22:58,203 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [WicketRequest] 08:22:58,203 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Pushing component [filter] on top of the object stack. 08:22:58,203 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Pushing component [rollingPolicy] on top of the object stack. 08:22:58,204 |-INFO in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@2b7ba0b3 - Adding parent to RollingPolicy: WicketRequest 08:22:58,204 |-INFO in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@2b7ba0b3 - Will use gz compression 08:22:58,204 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Pushing component [triggeringPolicy] on top of the object stack. 08:22:58,205 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[WicketRequest] - Active log file name: /usr/local/apache-tomcat6.0/logs/wicketRequest.log 08:22:58,205 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[WicketRequest] - File property is set to [/usr/local/apache-tomcat6.0/logs/wicketRequest.log] 08:22:58,205 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Popping appender named [WicketRequest] from the object stack 08:22:58,205 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender] 08:22:58,206 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT] 08:22:58,207 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Popping appender named [STDOUT] from the object stack 08:22:58,207 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.classic.net.SMTPAppender] 08:22:58,269 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [EMAIL] 08:22:58,333 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Popping appender named [EMAIL] from the object stack 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.springframework] to true 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - org.springframework level set to DEBUG 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.hibernate.cache] to true 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - org.hibernate.cache level set to DEBUG 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [com.resprompt] to true 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - com.resprompt level set to DEBUG 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [com.sun.facelets] to true 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - com.sun.facelets level set to DEBUG 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.springframework.orm] to true 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - org.springframework.orm level set to INFO 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.hibernate.SQL] to true 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - org.hibernate.SQL level set to DEBUG 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.hibernate.transaction] to true 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - org.hibernate.transaction level set to DEBUG 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.hibernate] to true 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - org.hibernate level set to INFO 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.hibernate.tool.hbm2ddl] to true 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - org.hibernate.tool.hbm2ddl level set to DEBUG 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.directwebremoting] to true 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - org.directwebremoting level set to INFO 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.springframework.transaction] to true 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - org.springframework.transaction level set to INFO 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.springmodules.cache] to true 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - org.springmodules.cache level set to DEBUG 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.apache.commons.digester] to true 08:22:58,333 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - org.apache.commons.digester level set to INFO 08:22:58,334 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.apache.wicket.protocol.http.RequestLogger] to false 08:22:58,334 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [WicketRequest] to Logger[org.apache.wicket.protocol.http.RequestLogger] 08:22:58,335 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - root level set to DEBUG 08:22:58,335 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [EMAIL] to Logger[root] 08:22:58,336 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [R] to Logger[root] 08:22:58,336 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
Thanks Gianni
On 15/gen/09, at 07:41, Gianni Doe wrote:
Hi My log files are not rolling over with the following appender and they grow indefinitely in size:
<appender class="ch.qos.logback.core.rolling.RollingFileAppender" name="R"> <File>${catalina.home}/logs/rp.log</File> <Append>true</Append> <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> <level>debug</level> </filter> <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> <FileNamePattern>rp.%i.log.gz</FileNamePattern> <MinIndex>1</MinIndex> <MaxIndex>3</MaxIndex> </rollingPolicy> <TriggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> <MaxFileSize>5MB</MaxFileSize> </TriggeringPolicy> <layout class="ch.qos.logback.classic.PatternLayout"> <Pattern>%-30(%d{HH:mm:ss.SSS} [%thread]) %-5level %logger{64} - %msg %n</Pattern> </layout> </appender>
At some point this appender was working correctly so I'm a bit baffled - any suggestions for debugging why it's not working would be appreciated. Thanks Gianni
PS. Not sure if this is relevant but I've been upgrading logback as new versions have been released but I couldn't say if it stopped working with a particular release or not.
-- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch

Thanks Ceki I can confirm at is now working fine with full path specified. -GIanni On 16/gen/09, at 11:29, Ceki Gulcu wrote:
Hello Gianni,
I have opened a jira issue regarding this problem. Its url is http://jira.qos.ch/browse/LBCLASSIC-105
Looking at the configuration file, the File property reads "${catalina.home}/logs/rp.log" while the FileNamePattern property is set to "rp.%i.log.gz". This means that the archived files will be located in current folder. If you wish to have the archived files located next to the current log file, you need to set FileNamePattern property to "${catalina.home}/logs/rp.%i.log.gz"
I have tested your configuration file, and it seems to work just fine.
If there are indeed problems with the roll over, they should be visible by printing logback's internal status. Here is code that does that:
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); StatusPrinter.print(lc);
Invoke it after roll over occurs or at application exit.
participants (2)
-
Ceki Gulcu
-
Gianni Doe