Skip to content

Commit

Permalink
Fixed a bug in TimeBasedFileNamingAndTriggeringPolicyBase
Browse files Browse the repository at this point in the history
Fixed a bug in TimeBasedFileNamingAndTriggeringPolicyBase
causing the policy to always rollover according to the
local system time and ignore the time zone passed in the
file name pattern. LOGBACK-611 introduced the
possibility to specify time zone in the file name pattern
and the file names are now correctly created according to
the specified time zone. However, rollover is still based
on the old behaviour, e.g., if the pattern is set to
/wombat/foo.{%d, UTC}, rollover will happen at midnight
of the local system time, instead of midnight in UTC. If
for example the log is created at 00:59+01:00 02/01/2015
(local system time), the rollover will happen at
00:00+01:00 03/01/2015 instead of 01:00+01:00 02/01/2015
(i.e., 00:00Z 02/01/2015).

qos-ch/logback@077e45c8f
  • Loading branch information
tony19 committed Sep 15, 2018
1 parent 3e75b36 commit bba846c
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import java.io.File;
import java.util.Date;
import java.util.Locale;

import ch.qos.logback.core.rolling.helper.ArchiveRemover;
import ch.qos.logback.core.rolling.helper.DateTokenConverter;
Expand Down Expand Up @@ -48,7 +49,11 @@ public void start() {
+ "] does not contain a valid DateToken");
}

rc = new RollingCalendar();
if (dtc.getTimeZone() != null) {
rc = new RollingCalendar(dtc.getTimeZone(), Locale.US);
} else {
rc = new RollingCalendar();
}
rc.init(dtc.getDatePattern());
addInfo("The date pattern is '" + dtc.getDatePattern()
+ "' from file name pattern '" + tbrp.fileNamePattern.getPattern()
Expand Down

0 comments on commit bba846c

Please sign in to comment.