[logback-user] issue with RollingFileAppender when File matches FileNamePattern

Karl Pietrzak kap4020 at gmail.com
Tue Jan 8 02:23:28 CET 2013


Hello everyone!

I've come across an issue with RollingFileAppender, but I'm not sure if
it's us or logback.

<configuration>

    <timestamp key="currentDate" datePattern="yyyy_MM_dd" />

    <appender name="dataServiceRequestLog"
class="ch.qos.logback.core.rolling.RollingFileAppender">
 <param name="File" value="${the.log.dir}/${currentDate}.WebService.log"/>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">

<FileNamePattern>${the.log.dir}/%d{yyyy_MM_dd}.WebService.log</FileNamePattern>
<MaxHistory>30</MaxHistory>
 </rollingPolicy>
        <encoder
class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level - %msg%n</pattern>
        </encoder>
</appender>

The curious part is that File matches the FileNamePattern for the rolling
policy ("${the.log.dir}/${currentDate}.WebService.log" and
"${the.log.dir}/%d{yyyy_MM_dd}.WebService.log").

Do you guys think that's OK?  The intention is that there's a separate file
for every day:

   - 2013_01_03.WebService.log
   - 2013_01_04.WebService.log
   - 2013_01_05.WebService.log
   - 2013_01_06.WebService.log

The issue we're experiencing is seemingly random writes to old log files
(e.g., today we saw writes to 2013_01_04.WebService.log). Could this be the
rename problem?

Perhaps there's a better way to achieve the desired functionality.  Is this
worth writing a unit test for in RollingFileAppenderTest.java?

Any tips are greatly appreciated, thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20130107/c2046922/attachment.html>


More information about the Logback-user mailing list