[logback-user] RollingFileAppender with SizeBasedTriggeringPolicy keeps writing to rotated file
ceki
ceki at qos.ch
Fri May 24 18:26:47 CEST 2013
Hi Rolando,
Thank you for posting your logback.xml file. I suspect that for some
reason logback is unable to rename some of the archives.
In any case, setting the debug attribute to true in <configuration>
element should provide helpful clues as to what is going on during
file rolling. Here is the modified <configuration> element:
<configuration debug="true" scan="true">
...
</configuration>
Please post the status messages on this list.
On 24.05.2013 17:53, Rolando Segura wrote:
> Hi David,
> Configuration is below. I'm also showing the sizes of the log files,
> you'll notice that some of them have sizes much larger to what is
> specified with the MaxFileSize parameter of the triggering policy.
>
> Thanks,
> Rolando
>
>
> $ ls -l /opt/log/mop.log*
> -rw-r--r-- 1 wps wps 13366643 May 24 09:47 /opt/log/mop.log
> -rw-r--r-- 1 wps wps 67121376 May 24 09:16 /opt/log/mop.log.1
> -rw-r--r-- 1 wps wps 849229334 May 24 09:47 /opt/log/mop.log.10
> -rw-r--r-- 1 wps wps 67116193 May 23 23:16 /opt/log/mop.log.2
> -rw-r--r-- 1 wps wps 67114690 May 23 19:54 /opt/log/mop.log.3
> -rw-r--r-- 1 wps wps 31160111 May 24 09:47 /opt/log/mop.log.4
> -rw-r--r-- 1 wps wps 67110076 May 23 17:09 /opt/log/mop.log.5
> -rw-r--r-- 1 wps wps 67115644 May 23 11:38 /opt/log/mop.log.6
> -rw-r--r-- 1 wps wps 67121760 May 23 00:31 /opt/log/mop.log.7
> -rw-r--r-- 1 wps wps 29536505 May 23 17:09 /opt/log/mop.log.8
> -rw-r--r-- 1 wps wps 2053363264 May 24 09:47 /opt/log/mop.log.9
>
> $ ls -l /opt/log/mop.nocr*
> -rw-r--r-- 1 wps wps 25664997 May 24 09:47 /opt/log/mop.nocrlf.log
> -rw-r--r-- 1 wps wps 991283661 May 24 09:47 /opt/log/mop.nocrlf.log.1
>
>
>
> $ cat logback.xml
> <?xml version="1.0" encoding="UTF-8"?>
>
> <!-- For assistance related to logback-translator or configuration -->
> <!-- files in general, please contact the logback user mailing list -->
> <!-- at http://www.qos.ch/mailman/listinfo/logback-user -->
> <!-- -->
> <!-- For professional support please see -->
> <!-- http://www.qos.ch/shop/products/professionalSupport -->
> <!-- -->
> <configuration scan="true">
> <appender name="SYSLOG"
> class="ch.qos.logback.classic.net.SyslogAppender">
> <syslogHost>localhost</syslogHost>
> <facility>LOCAL7</facility>
> <suffixPattern>%d{ISO8601} %5p [%t] \(%logger\) -
> %replace(%m){'\n',''}</suffixPattern>
> </appender>
> <appender name="mop"
> class="ch.qos.logback.core.rolling.RollingFileAppender">
> <!--See also
> http://logback.qos.ch/manual/appenders.html#RollingFileAppender-->
> <File>/opt/log/mop.log</File>
> <encoder>
> <pattern>%d{ISO8601} %5p [%t] \(%logger\) - %m%n</pattern>
> </encoder>
> <rollingPolicy
> class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
> <maxIndex>10</maxIndex>
> <FileNamePattern>/opt/log/mop.log.%i</FileNamePattern>
> </rollingPolicy>
> <triggeringPolicy
> class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
> <MaxFileSize>64MB</MaxFileSize>
> </triggeringPolicy>
> </appender>
> <appender name="mopnocrlf"
> class="ch.qos.logback.core.rolling.RollingFileAppender">
> <File>/opt/log/mop.nocrlf.log</File>
> <encoder>
> <pattern>[%d{ISO8601}] %5p [%t] \(%logger\) -
> %replace(%m){'\r?\n',''}%n</pattern>
> </encoder>
> <rollingPolicy
> class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
> <maxIndex>1</maxIndex>
> <FileNamePattern>/opt/log/mop.nocrlf.log.%i</FileNamePattern>
> </rollingPolicy>
> <triggeringPolicy
> class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
> <MaxFileSize>32MB</MaxFileSize>
> </triggeringPolicy>
> </appender>
> <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
> <encoder>
> <pattern>%5p [%t] \(%logger\) - %m%n</pattern>
> </encoder>
> </appender>
> <logger name="mop" level="debug">
> <appender-ref ref="mop"/>
> <appender-ref ref="mopnocrlf"/>
> </logger>
> <root level="fatal">
> <appender-ref ref="stdout"/>
> </root>
> </configuration>
>
>
>
> On Fri, May 24, 2013 at 7:21 AM, David Roussel
> <nabble at diroussel.xsmail.com <mailto:nabble at diroussel.xsmail.com>> wrote:
>
> Roland,
>
> That sounds strange. Can you post your logback.xml file?
>
> David
>
> On 23 May 2013, at 00:03, Rolando Segura <rolandosegura at gmail.com
> <mailto:rolandosegura at gmail.com>> wrote:
>
> > Hi I have an RollingFileAppender with a triggering policy of
> rotating by size when the log reaches 32MB and a maxIndex of 1,
> configuration below.
> > It happens that after rotation logback keeps writing to both
> files. Is this expected? My understanding from documentation is that
> it will stop writing to the current log, rename it and starts
> writing a to a new file with the name of the File parameter.
> >
> > I'd appreciate your clarification if I'm not understanding well
> the RollingFileAppender and SizeBasedTriggering behavior.
> >
> > Thanks,
> > Rolando
> >
> >
> >
> > <appender name="lognocrlf"
> class="ch.qos.logback.core.rolling.RollingFileAppender">
> > <File>/opt/log/file.nocrlf.log</File>
> > <encoder>
> > <pattern>[%d{ISO8601}] %5p [%t] \(%logger\) -
> %replace(%m){'\r?\n',''}%n</pattern>
> > </encoder>
> > <rollingPolicy
> class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
> > <maxIndex>1</maxIndex>
> > <FileNamePattern>/opt/log/file.nocrlf.log.%i</FileNamePattern>
> > </rollingPolicy>
> > <triggeringPolicy
> class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
> > <MaxFileSize>32MB</MaxFileSize>
> > </triggeringPolicy>
> > </appender>
> >
--
Ceki
65% of statistics are made up on the spot
More information about the Logback-user
mailing list