File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed
log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -506,9 +506,16 @@ public synchronized void rollover() {
506506
507507 if (rollover (rolloverStrategy )) {
508508 try {
509- size = 0 ;
510- initialTime = System .currentTimeMillis ();
511509 createFileAfterRollover ();
510+ final File file = new File (getFileName ());
511+ size = file .length ();
512+ try {
513+ final FileTime creationTime = (FileTime ) Files .getAttribute (file .toPath (), "creationTime" );
514+ initialTime = creationTime .toMillis ();
515+ } catch (Exception ex ) {
516+ LOGGER .warn ("Unable to get current file time for {}" , file );
517+ initialTime = System .currentTimeMillis ();
518+ }
512519 } catch (final IOException e ) {
513520 logError ("Failed to create file after rollover" , e );
514521 }
@@ -636,7 +643,7 @@ private boolean rollover(final RolloverStrategy strategy) {
636643 asyncExecutor .execute (new AsyncAction (descriptor .getAsynchronous (), this ));
637644 releaseRequired = false ;
638645 }
639- return success ;
646+ return true ;
640647 }
641648 return false ;
642649 } finally {
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <entry xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
3+ xmlns =" https://logging.apache.org/xml/ns"
4+ xsi : schemaLocation =" https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
5+ type =" fixed" >
6+ <issue id =" 2592" link =" https://github.com/apache/logging-log4j2/issues/2592" />
7+ <description format =" asciidoc" >Fix `RollingFileManager` to reopen the log file when the rollover was unsuccessful</description >
8+ </entry >
You can’t perform that action at this time.
0 commit comments