Index: logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java =================================================================== --- logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java (revision 2) +++ logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java Wed Jun 10 14:10:12 PDT 2009 @@ -1,8 +1,8 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * + * * Copyright (C) 1999-2006, QOS.ch - * + * * This library is free software, you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation. @@ -26,10 +26,10 @@ * TimeBasedRollingPolicy is both easy to configure and quite * powerful. It allows the roll over to be made based on time. It is possible to * specify that the roll over occur once per day, per week or per month. - * + * *

For more information, please refer to the online manual at * http://logback.qos.ch/manual/appenders.html#TimeBasedRollingPolicy - * + * * @author Ceki Gülcü */ public class TimeBasedRollingPolicy extends RollingPolicyBase implements @@ -131,12 +131,12 @@ } } - + public CompressionMode getCompressionMode() { return compressionMode; } - + // allow Test classes to act on the lastCheck field to simulate old // log files needing rollover void setLastCheck(Date _lastCheck) { @@ -152,19 +152,16 @@ // when rollover is called the elapsed period's file has // been already closed. This is a working assumption of this method. - + - if(compressionMode == CompressionMode.NONE) { - if (getParentsRawFileProperty() != null) { - util.rename(getParentsRawFileProperty(), elapsedPeriodsFileName); - } + if (getParentsRawFileProperty() != null) { + util.rename(getParentsRawFileProperty(), elapsedPeriodsFileName); + } - } else { - if(getParentsRawFileProperty() == null) { - doCompression(false, elapsedPeriodsFileName, elapsedPeriodsFileName); - } else { - doCompression(true, elapsedPeriodsFileName, elapsedPeriodsFileName); + + if(compressionMode != CompressionMode.NONE) { + doCompression(rolloverTargetIsParentFile(), elapsedPeriodsFileName, + elapsedPeriodsFileName); - } + } - } - + if (tbCleaner != null) { tbCleaner.clean(new Date(getCurrentTime())); } @@ -201,24 +198,24 @@ } /** - * + * * The active log file is determined by the value of the parent's filename * option. However, in case the file name is left blank, then, the active log * file equals the file name for the current period as computed by the * FileNamePattern option. - * + * *

The RollingPolicy must know whether it is responsible for changing the * name of the active file or not. If the active file name is set by the user * via the configuration file, then the RollingPolicy must let it like it is. * If the user does not specify an active file name, then the RollingPolicy * generates one. - * + * *

To be sure that the file name used by the parent class has been * generated by the RollingPolicy and not specified by the user, we keep track * of the last generated name object and compare its reference to the parent * file name. If they match, then the RollingPolicy knows it's responsible for * the change of the file name. - * + * */ public String getActiveFileName() { if (getParentsRawFileProperty() == null) { @@ -250,7 +247,7 @@ /** * Get the number of archive files to keep. - * + * * @return number of archive files to keep */ public int getMaxHistory() { @@ -259,7 +256,7 @@ /** * Set the maximum number of archive files to keep. - * + * * @param maxHistory * number of archive files to keep */