svn commit: r859 - in logback/trunk: logback-core/src/main/java/ch/qos/logback/core/rolling logback-site/src/site/fml

Author: seb Date: Thu Nov 2 21:03:48 2006 New Revision: 859 Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/FixedWindowRollingPolicy.java logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingFileAppender.java logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java logback/trunk/logback-site/src/site/fml/codes.fml Log: Moved tests to getNewActiveFileName method Added an entry to codes.fml when filename is not set Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/FixedWindowRollingPolicy.java ============================================================================== --- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/FixedWindowRollingPolicy.java (original) +++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/FixedWindowRollingPolicy.java Thu Nov 2 21:03:48 2006 @@ -21,7 +21,7 @@ * according to a fixed window algorithm as described below. * * <p> - * The <b>ActiveFileName</b> property, which is required, represents the name + * The <b>File</b> property, which is required, represents the name * of the file where current logging output will be written. The * <b>FileNamePattern</b> option represents the file name pattern for the * archived (rolled over) log files. If present, the <b>FileNamePattern</b> @@ -54,6 +54,7 @@ public class FixedWindowRollingPolicy extends RollingPolicyBase { static final String FNP_NOT_SET = "The FileNamePattern option must be set before using FixedWindowRollingPolicy. "; static final String SEE_FNP_NOT_SET = "See also http://logback.qos.ch/codes.html#tbr_fnp_not_set"; + static final String SEE_PARENT_FN_NOT_SET = "Please refer to http://logback.qos.ch/codes.html#fwrp_parentFileName_not_set"; int maxIndex; int minIndex; RenameUtil util = new RenameUtil(); @@ -82,9 +83,10 @@ addWarn(SEE_FNP_NOT_SET); throw new IllegalStateException(FNP_NOT_SET + SEE_FNP_NOT_SET); } - // if (activeFileName == null) { - if (getNewActiveFileName() == null) { - addWarn("The ActiveFile name option must be set before using this rolling policy."); + + if (getParentFileName() == null) { + addWarn("The File name option must be set before using this rolling policy."); + addWarn(SEE_PARENT_FN_NOT_SET); throw new IllegalStateException("The ActiveFileName option must be set."); } Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingFileAppender.java ============================================================================== --- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingFileAppender.java (original) +++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingFileAppender.java Thu Nov 2 21:03:48 2006 @@ -81,9 +81,7 @@ if (rollingPolicy != null) { //if no active file name was set, then it's the responsability of the //rollingPolicy to create one. - if (getFile() == null) { - setFile(rollingPolicy.getNewActiveFileName()); - } + setFile(rollingPolicy.getNewActiveFileName()); activeFileCache = new File(getFile()); addInfo("Active log file name: "+ getFile()); Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java ============================================================================== --- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java (original) +++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java Thu Nov 2 21:03:48 2006 @@ -246,11 +246,9 @@ } } - //if we already generated a name, then we have to update - //the fileAppender with a new active file name. - if (getParentFileName() == lastGeneratedFileName) { - setParentFileName(getNewActiveFileName()); - } + //let's update the parent active file name + setParentFileName(getNewActiveFileName()); + } /** @@ -273,16 +271,16 @@ * the RollingPolicy knows it's responsible for the change of the * file name. * - * - * tmp note: !!!!! This is called only once at the start of the appender, - * and only if the parent file name is null, so no test is required. - * */ public String getNewActiveFileName() { - String newName = activeFileNamePattern.convertDate(lastCheck); - addInfo("Generated a new name for RollingFileAppender: " + newName); - lastGeneratedFileName = newName; - return newName; + if (getParentFileName() == null || getParentFileName() == lastGeneratedFileName) { + String newName = activeFileNamePattern.convertDate(lastCheck); + addInfo("Generated a new name for RollingFileAppender: " + newName); + lastGeneratedFileName = newName; + return newName; + } else { + return getParentFileName(); + } } public boolean isTriggeringEvent(File file, final Object event) { Modified: logback/trunk/logback-site/src/site/fml/codes.fml ============================================================================== --- logback/trunk/logback-site/src/site/fml/codes.fml (original) +++ logback/trunk/logback-site/src/site/fml/codes.fml Thu Nov 2 21:03:48 2006 @@ -39,8 +39,31 @@ for more information. </p> </answer> - </faq> + + <faq id="fwrp_parentFileName_not_set"> + + <question> + <p>The File name option must be set before <code>FixedWindowRollingPolicy</code>.</p> + </question> + + <answer> + <p> + The <span class="option">File</span> option is mandatory with <code>FixedWindowRollingPolicy</code>. Moreover, the File option must be + set before the declaration configuring <code>FixedWindowRollingPolicy</code>. + </p> + <p> + See the logback manual's chapter about + <a + href="http://logback.qos.ch/manual/appenders.html#FixedWindowRollingPolicy"> + FixedWindowRollingPolicy + </a> + for more information. + </p> + </answer> + </faq> + + <faq id="socket_no_host"> <question> No remote host or address is set for
participants (1)
-
noreply.seb@qos.ch