[ https://issues.apache.org/jira/browse/LOG4J2-1906?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16702635#comment-16702635 ]
Gary Gregory commented on LOG4J2-1906: -------------------------------------- On my machine, I get: {noformat} java.lang.AssertionError: target\rollOnStartup\testfile expected:<0> but was:<12> at org.junit.Assert.fail(Assert.java:88) at org.junit.Assert.failNotEquals(Assert.java:834) at org.junit.Assert.assertEquals(Assert.java:645) at org.apache.logging.log4j.core.appender.rolling.OnStartupTriggeringPolicyTest.testPolicy(OnStartupTriggeringPolicyTest.java:88) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48) at org.junit.rules.RunRules.evaluate(RunRules.java:20) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209) {noformat} This is on Windows 10 with Oracle Java 7. > DirectWriteRolloverStrategy not properly creating files > ------------------------------------------------------- > > Key: LOG4J2-1906 > URL: https://issues.apache.org/jira/browse/LOG4J2-1906 > Project: Log4j 2 > Issue Type: Bug > Affects Versions: 2.8.2 > Reporter: João Santos > Assignee: Ralph Goers > Priority: Major > Fix For: 3.0.0, 2.11.2 > > > The DirectWriteRolloverStrategy is not properly determining the filename of > the new log file after the rollover happens. > With the following configuration: > {noformat} > <RollingFile name="ApplicationLog" > filePattern="application.log.%d{yyyy-MM-dd-HH-mm}"> > <PatternLayout> > <Pattern>%m%n</Pattern> > </PatternLayout> > <Policies> > <TimeBasedTriggeringPolicy /> > <SizeBasedTriggeringPolicy /> > </Policies> > <DirectWriteRolloverStrategy /> > </RollingFile> > {noformat} > What is happening is, for instance: > - application starts at 09h35m30s > - at instant 09h35m55s a new log is written the rollover is set to happen at > 09h36m00s, log line is written to application.log.2017-05-10-09-35 - OK > - at instant 09h36m05s a new log is written and the rollover is triggered, > after the rollover logs are written to application.log.2017-05-10-09-35 - Not > OK > - at instant 09h37m05s a new log is written and the rollover is triggered, > after the rollover logs are written to application.log.2017-05-10-09-36 - Not > OK > This seems to be happening because > DirectWriteRolloverStrategy.getCurrentFileName (when being called from > createFileAfterRollover) is calling the PatternProcessor.formatFileName and > telling it to use the currentTime. However, currentFileTime is zero, and it > will fallback to the prevFileTime to determine the filename, which is wrong > as it will be one minute before current time. > It should probably either use the nextFileTime (while debugging I could see > that it was set to the correct time, the minute I expect the file to > rollover), or use the System time. -- This message was sent by Atlassian JIRA (v7.6.3#76005)