<div dir="ltr">Hi Ceki,<div>Indeed, setting the maxFileSize property on SizeAndTimeBasedFNATP resolved the problem. Thanks as well for the tip on <span style="font-size:12.8px">SizeAndTimeBasedRollingPolicy - turns out that some of our projects are already using that in their configs, but I happened to be looking at one that wasn't.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Thanks,</span></div><div><span style="font-size:12.8px">Alex</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 13, 2016 at 4:12 AM, Ceki Gulcu <span dir="ltr"><<a href="mailto:ceki@qos.ch" target="_blank">ceki@qos.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Alex,<br>
<br>
Thank you for the detailed description of the problem allowing its easy reproduction. It turns our that the configuration directives for ROLLING-FILE is lacking a crucial element, namely the "maxFileSize" property.<br>
<br>
This would have been evident if you had enabled logback's internal status messages with<br>
<br>
<configuration debug="true"><br>
 ...<br>
</configuration><br>
<br>
or with the equivalent<br>
<br>
<configuration><br>
  <statusListener<br>
class="ch.qos.logback.core.status.OnConsoleStatusListener" /><br>
  ...<br>
</configuration><br>
<br>
I have modified the code of SizeAndTimeBasedFNATP to detect the missing the "maxFileSize" property sooner and immediately alert the user.<br>
<br>
Also note that more recent versions of logback ship with SizeAndTimeBasedRollingPolicy [1] which offers a more pleasant syntax than the TimeBasedRollingPolicy+SizeAndTimeBasedFNATP combination but with exactly the same functionality.<br>
<br>
Cheers,<br>
<br>
--<br>
Ceki<br>
<br>
[1] <a href="http://logback.qos.ch/manual/appenders.html#SizeAndTimeBasedRollingPolicy" rel="noreferrer" target="_blank">http://logback.qos.ch/manual/appenders.html#SizeAndTimeBasedRollingPolicy</a><div><div class="h5"><br>
<br>
On 5/5/2016 16:42, Alex Hall wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
Greetings, logback-users.<br>
<br>
We recently switched from log4j to logback, and have observed some<br>
concerning behavior with RollingFileAppender - namely, it seems to be<br>
dropping log messages in what turns out to be a predictable manner. I'm<br>
including a simple test program that I wrote to illustrate the issue.<br>
Basically, the output of the test program indicates that the<br>
RollingFileAppender is dropping messages 16, 32, 64, 128, and so on.<br>
<br>
Is this a known issue with RollingFileAppender? Is there some sort of<br>
error in our logback configuration? Any help is appreciated!<br>
<br>
Regards,<br>
Alex Hall<br>
<br>
==========<br>
<br>
Operating system: Ubuntu 14.04 LTS<br>
Java version: Oracle JDK 1.8.0u72<br>
<br>
Test program:<br>
<br>
/lib:<br>
   + logback-classic-1.1.7.jar<br>
   + logback-core-1.1.7.jar<br>
   + slf4j-api-1.7.21.jar<br>
<br>
/resources/logback-test.xml:<br>
----------<br>
<configuration><br>
<br>
   <appender name="FILE" class="ch.qos.logback.core.FileAppender"><br>
     <file>logs/test.log</file><br>
     <encoder><br>
       <pattern>%d [%thread] %-5level %logger{36} - %msg%n</pattern><br>
     </encoder><br>
   </appender><br>
<br>
   <appender name="ROLLING-FILE"<br>
class="ch.qos.logback.core.rolling.RollingFileAppender"><br>
     <file>logs/rolling-test.log</file><br>
     <encoder><br>
       <pattern>%d [%thread] %-5level %logger{36} - %msg%n</pattern><br>
     </encoder><br>
     <rollingPolicy<br>
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"><br>
<br>
<fileNamePattern>logs/rolling-test-%d{yyyy-MM-dd}.%i.log</fileNamePattern><br>
       <timeBasedFileNamingAndTriggeringPolicy<br>
           class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP" /><br>
       <maxHistory>30</maxHistory><br>
       <cleanHistoryOnStart>true</cleanHistoryOnStart><br>
     </rollingPolicy><br>
   </appender><br>
<br>
   <root level="INFO"><br>
     <appender-ref ref="FILE" /><br>
     <appender-ref ref="ROLLING-FILE" /><br>
   </root><br>
<br>
</configuration><br>
----------<br>
<br>
/src/RollingAppenderTest.java:<br>
----------<br>
import org.slf4j.Logger;<br>
import org.slf4j.LoggerFactory;<br>
<br>
public class RollingAppenderTest {<br>
    private static final Logger log =<br>
LoggerFactory.getLogger(RollingAppenderTest.class);<br>
<br>
    public static void main(String[] args) throws Exception {<br>
       if (args.length != 1) {<br>
          System.out.println("Usage: java RollingAppenderTest<br>
<num-messages>");<br>
          System.exit(1);<br>
       }<br>
<br>
       int nMessages = Integer.parseInt(args[0]);<br>
<br>
       for (int i = 1; i <= nMessages; i++) {<br>
</div></div><a href="http://log.info" rel="noreferrer" target="_blank">log.info</a> <<a href="http://log.info" rel="noreferrer" target="_blank">http://log.info</a>>("Hello, " + i);<div><div class="h5"><br>
       }<br>
    }<br>
}<br>
----------<br>
<br>
/run-test.sh<br>
----------<br>
#!/bin/sh<br>
<br>
rm -rf logs<br>
rm -rf classes<br>
<br>
echo "Compiling..."<br>
mkdir classes<br>
javac -cp 'lib/*' -d classes -sourcepath src src/*.java<br>
<br>
echo "Running..."<br>
java -cp 'lib/*:classes:resources' RollingAppenderTest $1<br>
<br>
echo "FileAppender output lines:        $(wc -l logs/test.log)"<br>
echo "RollingFileAppender output lines: $(wc -l logs/rolling-test.log)"<br>
diff logs/test.log logs/rolling-test.log<br>
----------<br>
<br>
Test output:<br>
----------<br>
alex@alex-ubuntu14:~/src/scratch/logback-drops-messages$ ./run-test.sh 1000<br>
Compiling...<br>
Running...<br>
FileAppender output lines:        1000 logs/test.log<br>
RollingFileAppender output lines: 994 logs/rolling-test.log<br>
16d15<br>
< 2016-05-05 14:40:14,365 [main] INFO  RollingAppenderTest - Hello, 16<br>
32d30<br>
< 2016-05-05 14:40:14,366 [main] INFO  RollingAppenderTest - Hello, 32<br>
64d61<br>
< 2016-05-05 14:40:14,380 [main] INFO  RollingAppenderTest - Hello, 64<br>
128d124<br>
< 2016-05-05 14:40:14,383 [main] INFO  RollingAppenderTest - Hello, 128<br>
256d251<br>
< 2016-05-05 14:40:14,405 [main] INFO  RollingAppenderTest - Hello, 256<br>
512d506<br>
< 2016-05-05 14:40:14,439 [main] INFO  RollingAppenderTest - Hello, 512<br>
----------<br>
<br>
<br></div></div>
_______________________________________________<br>
logback-user mailing list<br>
<a href="mailto:logback-user@qos.ch" target="_blank">logback-user@qos.ch</a><br>
<a href="http://mailman.qos.ch/mailman/listinfo/logback-user" rel="noreferrer" target="_blank">http://mailman.qos.ch/mailman/listinfo/logback-user</a><br>
<br>
</blockquote>
_______________________________________________<br>
logback-user mailing list<br>
<a href="mailto:logback-user@qos.ch" target="_blank">logback-user@qos.ch</a><br>
<a href="http://mailman.qos.ch/mailman/listinfo/logback-user" rel="noreferrer" target="_blank">http://mailman.qos.ch/mailman/listinfo/logback-user</a></blockquote></div><br></div>