carnold     2005/05/07 20:43:41

  Modified:    src/java/org/apache/log4j/rolling
                        FilterBasedTriggeringPolicy.java
                        FixedWindowRollingPolicy.java
                        RollingFileAppender.java RollingPolicy.java
                        RollingPolicyBase.java
                        SizeBasedTriggeringPolicy.java
                        TimeBasedRollingPolicy.java TriggeringPolicy.java
               tests/src/java/org/apache/log4j/rolling
                        SizeBasedRollingTest.java
  Log:
  Bug 34800: Size based rolling inaccurate on Windows
  
  Revision  Changes    Path
  1.2       +7 -2      
logging-log4j/src/java/org/apache/log4j/rolling/FilterBasedTriggeringPolicy.java
  
  Index: FilterBasedTriggeringPolicy.java
  ===================================================================
  RCS file: 
/home/cvs/logging-log4j/src/java/org/apache/log4j/rolling/FilterBasedTriggeringPolicy.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FilterBasedTriggeringPolicy.java  12 Feb 2005 03:10:27 -0000      1.1
  +++ FilterBasedTriggeringPolicy.java  8 May 2005 03:43:40 -0000       1.2
  @@ -19,6 +19,7 @@
   import org.apache.log4j.spi.Filter;
   import org.apache.log4j.spi.LoggingEvent;
   
  +import org.apache.log4j.Appender;
   import java.io.File;
   
   
  @@ -50,12 +51,16 @@
   
     /**
      *  Determines if the event should trigger a rollover.
  -   *  @param file rolling file, ignored.
  +   *  @param appender appender, ignored.
  +   *  @param fileLength file length in bytes, ignored.
      *  @param event logging event.
      *  @return true if event should trigger a rollover.
      *
      */
  -  public boolean isTriggeringEvent(final File file, final LoggingEvent 
event) {
  +  public boolean isTriggeringEvent(final Appender appender,
  +                                   final LoggingEvent event,
  +                                   final File file,
  +                                   final long fileLength) {
       //
       //   in the abnormal case of no contained filters
       //     always return true to avoid each logging event 
  
  
  
  1.8       +1 -1      
logging-log4j/src/java/org/apache/log4j/rolling/FixedWindowRollingPolicy.java
  
  Index: FixedWindowRollingPolicy.java
  ===================================================================
  RCS file: 
/home/cvs/logging-log4j/src/java/org/apache/log4j/rolling/FixedWindowRollingPolicy.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- FixedWindowRollingPolicy.java     6 Jan 2005 19:27:03 -0000       1.7
  +++ FixedWindowRollingPolicy.java     8 May 2005 03:43:40 -0000       1.8
  @@ -141,7 +141,7 @@
          if(toRename.exists()) {
              util.rename(toRenameStr, fileNamePattern.convert(i + 1));
          } else {
  -           getLogger().info("Skipping rollover for inexistent file {}", 
toRenameStr); 
  +           getLogger().info("Skipping rollover for non-existent file {}", 
toRenameStr); 
             }
         }
   
  
  
  
  1.25      +207 -136  
logging-log4j/src/java/org/apache/log4j/rolling/RollingFileAppender.java
  
  Index: RollingFileAppender.java
  ===================================================================
  RCS file: 
/home/cvs/logging-log4j/src/java/org/apache/log4j/rolling/RollingFileAppender.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- RollingFileAppender.java  8 Mar 2005 22:32:57 -0000       1.24
  +++ RollingFileAppender.java  8 May 2005 03:43:40 -0000       1.25
  @@ -1,19 +1,18 @@
   /*
    * Copyright 1999,2005 The Apache Software Foundation.
  - * 
  + *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
  - * 
  + *
    *      http://www.apache.org/licenses/LICENSE-2.0
  - * 
  + *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
    */
  -
   package org.apache.log4j.rolling;
   
   import org.apache.log4j.FileAppender;
  @@ -21,19 +20,21 @@
   
   import java.io.File;
   import java.io.IOException;
  +import java.io.OutputStream;
  +import java.io.OutputStreamWriter;
   
   
   /**
    * <code>RollingFileAppender</code> extends [EMAIL PROTECTED] FileAppender} 
to backup the log files
    * depending on [EMAIL PROTECTED] RollingPolicy} and [EMAIL PROTECTED] 
TriggeringPolicy}.
    * <p>
  - * To be of any use, a <code>RollingFileAppender</code> instance must have 
both 
  - * a <code>RollingPolicy</code> and a <code>TriggeringPolicy</code> set up. 
  + * To be of any use, a <code>RollingFileAppender</code> instance must have 
both
  + * a <code>RollingPolicy</code> and a <code>TriggeringPolicy</code> set up.
    * However, if its <code>RollingPolicy</code> also implements the
    * <code>TriggeringPolicy</code> interface, then only the former needs to be
    * set up. For example, [EMAIL PROTECTED] TimeBasedRollingPolicy} acts both 
as a
    * <code>RollingPolicy</code> and a <code>TriggeringPolicy</code>.
  - * 
  + *
    * <p><code>RollingFileAppender</code> can be configured programattically or
    * using [EMAIL PROTECTED] org.apache.log4j.joran.JoranConfigurator}. Here 
is a sample
    * configration file:
  @@ -50,148 +51,218 @@
   
       &lt;layout class="org.apache.log4j.PatternLayout">
         &lt;param name="ConversionPattern" value="%c{1} - %m%n"/>
  -    &lt;/layout>     
  +    &lt;/layout>
     &lt;/appender>
   
     &lt;root">
       &lt;appender-ref ref="ROLL"/>
     &lt;/root>
  - 
  +
   &lt;/log4j:configuration>
   </pre>
   
    *<p>This configuration file specifies a monthly rollover schedule including
  - * automatic compression of the archived files. See 
  + * automatic compression of the archived files. See
    * [EMAIL PROTECTED] TimeBasedRollingPolicy} for more details.
  - * 
  + *
    * @author Heinz Richter
    * @author Ceki G&uuml;lc&uuml;
    * @since  1.3
    * */
  -public class RollingFileAppender extends FileAppender {
  -  File activeFile;
  -  TriggeringPolicy triggeringPolicy;
  -  RollingPolicy rollingPolicy;
  -
  -  /**
  -   * The default constructor simply calls its [EMAIL PROTECTED]
  -   * FileAppender#FileAppender parents constructor}.
  -   * */
  -  public RollingFileAppender() {
  -  }
  -
  -  public void activateOptions() {
  -    if (triggeringPolicy == null) {
  -      getLogger().warn("Please set a TriggeringPolicy for the 
RollingFileAppender named '{}'", getName());
  -      return;
  -    }
  -
  -    if (rollingPolicy != null) {
  -      String afn = rollingPolicy.getActiveFileName();
  -      activeFile = new File(afn);
  -      getLogger().debug("Active log file name: "+afn);
  -      setFile(afn);
  -      
  -      // the activeFile variable is used by the 
triggeringPolicy.isTriggeringEvent method
  -      activeFile = new File(afn);
  -      super.activateOptions();
  -    } else {
  -      getLogger().warn("Please set a rolling policy");
  -    }
  -  }
  -
  -  /**
  -     Implements the usual roll over behaviour.
  -
  -     <p>If <code>MaxBackupIndex</code> is positive, then files
  -     {<code>File.1</code>, ..., <code>File.MaxBackupIndex -1</code>}
  -     are renamed to {<code>File.2</code>, ...,
  -     <code>File.MaxBackupIndex</code>}. Moreover, <code>File</code> is
  -     renamed <code>File.1</code> and closed. A new <code>File</code> is
  -     created to receive further log output.
  -
  -     <p>If <code>MaxBackupIndex</code> is equal to zero, then the
  -     <code>File</code> is truncated with no backup files created.
  -
  -   */
  -  public void rollover() {
  -    // Note: synchronization at this point is unnecessary as the doAppend 
  -    // is already synched
  -    
  -    //
  -    // make sure to close the hereto active log file! Renaming under windows
  -    // does not work for open files.
  -    this.closeWriter();    
  -    
  -    // By default, the newly created file will be created in truncate mode.
  -    // (See the setFile(fileName,...) call a few lines below.)
  -    boolean append = false;
  -    try { 
  -      rollingPolicy.rollover();
  -    } catch(RolloverFailure rf) {
  -      getLogger().warn("RolloverFailure occurred. Deferring rollover.");
  -      // we failed to rollover, let us not truncate and risk data loss
  -      append = true;
  -    }
  -    
  -    // Although not certain, the active file name may change after roll over.
  -    fileName = rollingPolicy.getActiveFileName();
  -    getLogger().debug("Active file name is now [{}].", fileName);
  -
  -    // the activeFile variable is used by the 
triggeringPolicy.isTriggeringEvent method
  -    activeFile = new File(fileName);
  -
  -    try {
  -      // This will also close the file. This is OK since multiple
  -      // close operations are safe.
  -      this.setFile(fileName, append, bufferedIO, bufferSize);
  -    } catch (IOException e) {
  -      getLogger().error(
  -        "setFile(" + fileName + ", false) call failed.", e);
  -    }
  -  }
  -
  -  /**
  -     This method differentiates RollingFileAppender from its super
  -     class.
  -  */
  -  protected void subAppend(LoggingEvent event) {
  -    // The rollover check must precede actual writing. This is the 
  -    // only correct behavior for time driven triggers. 
  -    if (triggeringPolicy.isTriggeringEvent(activeFile, event)) {
  -      getLogger().debug("About to rollover");
  -      rollover();
  -    }
  -      
  -    super.subAppend(event);
  -  }
  -
  -  public RollingPolicy getRollingPolicy() {
  -    return rollingPolicy;
  -  }
  -
  -  public TriggeringPolicy getTriggeringPolicy() {
  -    return triggeringPolicy;
  -  }
  -
  -  /**
  -   * Sets the rolling policy. In case the 'policy' argument also implements
  -   * [EMAIL PROTECTED] TriggeringPolicy}, then the triggering policy for 
this appender
  -   * is automatically set to be the policy argument.
  -   * @param policy
  -   */
  -  public void setRollingPolicy(RollingPolicy policy) {
  -    rollingPolicy = policy;
  -    if(rollingPolicy instanceof TriggeringPolicy) {
  -      triggeringPolicy = (TriggeringPolicy) policy;
  -    }
  -    
  -  }
  -
  -  public void setTriggeringPolicy(TriggeringPolicy policy) {
  -    triggeringPolicy = policy;
  -    if(policy instanceof RollingPolicy) {
  -      rollingPolicy = (RollingPolicy) policy;
  +public final class RollingFileAppender extends FileAppender {
  +    private File activeFile;
  +    private TriggeringPolicy triggeringPolicy;
  +    private RollingPolicy rollingPolicy;
  +    private long fileLength = 0;
  +
  +    /**
  +     * The default constructor simply calls its [EMAIL PROTECTED]
  +     * FileAppender#FileAppender parents constructor}.
  +     * */
  +    public RollingFileAppender() {
  +    }
  +
  +    public void activateOptions() {
  +        if (triggeringPolicy == null) {
  +            getLogger().warn("Please set a TriggeringPolicy for the 
RollingFileAppender named '{}'",
  +                getName());
  +
  +            return;
  +        }
  +
  +        if (rollingPolicy != null) {
  +            String afn = rollingPolicy.getActiveFileName();
  +            activeFile = new File(afn);
  +            getLogger().debug("Active log file name: " + afn);
  +            setFile(afn);
  +
  +            // the activeFile variable is used by the 
triggeringPolicy.isTriggeringEvent method
  +            activeFile = new File(afn);
  +
  +            if (this.getAppend()) {
  +                fileLength = activeFile.length();
  +            } else {
  +                fileLength = 0;
  +            }
  +
  +            super.activateOptions();
  +        } else {
  +            getLogger().warn("Please set a rolling policy");
  +        }
  +    }
  +
  +    /**
  +       Implements the usual roll over behaviour.
  +
  +       <p>If <code>MaxBackupIndex</code> is positive, then files
  +       {<code>File.1</code>, ..., <code>File.MaxBackupIndex -1</code>}
  +       are renamed to {<code>File.2</code>, ...,
  +       <code>File.MaxBackupIndex</code>}. Moreover, <code>File</code> is
  +       renamed <code>File.1</code> and closed. A new <code>File</code> is
  +       created to receive further log output.
  +
  +       <p>If <code>MaxBackupIndex</code> is equal to zero, then the
  +       <code>File</code> is truncated with no backup files created.
  +
  +     */
  +    public void rollover() {
  +        // Note: synchronization at this point is unnecessary as the 
doAppend 
  +        // is already synched
  +        //
  +        // make sure to close the hereto active log file! Renaming under 
windows
  +        // does not work for open files.
  +        this.closeWriter();
  +
  +        // By default, the newly created file will be created in truncate 
mode.
  +        // (See the setFile(fileName,...) call a few lines below.)
  +        boolean append = false;
  +
  +        try {
  +            rollingPolicy.rollover();
  +            fileLength = 0;
  +        } catch (RolloverFailure rf) {
  +            getLogger().warn("RolloverFailure occurred. Deferring 
rollover.");
  +
  +            // we failed to rollover, let us not truncate and risk data loss
  +            append = true;
  +        }
  +
  +        // Although not certain, the active file name may change after roll 
over.
  +        fileName = rollingPolicy.getActiveFileName();
  +        getLogger().debug("Active file name is now [{}].", fileName);
  +
  +        // the activeFile variable is used by the 
triggeringPolicy.isTriggeringEvent method
  +        activeFile = new File(fileName);
  +
  +        try {
  +            // This will also close the file. This is OK since multiple
  +            // close operations are safe.
  +            this.setFile(fileName, append, bufferedIO, bufferSize);
  +        } catch (IOException e) {
  +            getLogger().error("setFile(" + fileName + ", false) call 
failed.", e);
  +        }
  +    }
  +
  +    /**
  +       This method differentiates RollingFileAppender from its super
  +       class.
  +    */
  +    protected void subAppend(final LoggingEvent event) {
  +        // The rollover check must precede actual writing. This is the 
  +        // only correct behavior for time driven triggers. 
  +        if (triggeringPolicy.isTriggeringEvent(this, event, activeFile,
  +                    getFileLength())) {
  +            getLogger().debug("About to rollover");
  +            rollover();
  +        }
  +
  +        super.subAppend(event);
  +    }
  +
  +    public RollingPolicy getRollingPolicy() {
  +        return rollingPolicy;
  +    }
  +
  +    public TriggeringPolicy getTriggeringPolicy() {
  +        return triggeringPolicy;
  +    }
  +
  +    /**
  +     * Sets the rolling policy. In case the 'policy' argument also implements
  +     * [EMAIL PROTECTED] TriggeringPolicy}, then the triggering policy for 
this appender
  +     * is automatically set to be the policy argument.
  +     * @param policy
  +     */
  +    public void setRollingPolicy(final RollingPolicy policy) {
  +        rollingPolicy = policy;
  +
  +        if (rollingPolicy instanceof TriggeringPolicy) {
  +            triggeringPolicy = (TriggeringPolicy) policy;
  +        }
  +    }
  +
  +    public void setTriggeringPolicy(final TriggeringPolicy policy) {
  +        triggeringPolicy = policy;
  +
  +        if (policy instanceof RollingPolicy) {
  +            rollingPolicy = (RollingPolicy) policy;
  +        }
  +    }
  +
  +    /**
  +       Returns an OutputStreamWriter when passed an OutputStream.  The
  +       encoding used will depend on the value of the
  +       <code>encoding</code> property.  If the encoding value is
  +       specified incorrectly the writer will be opened using the default
  +       system encoding (an error message will be printed to the loglog.  */
  +    protected OutputStreamWriter createWriter(final OutputStream os) {
  +        return super.createWriter(new CountingOutputStream(os, this));
  +    }
  +
  +    public long getFileLength() {
  +        return fileLength;
  +    }
  +
  +    public void incrementFileLength(int increment) {
  +        fileLength += increment;
  +    }
  +
  +    /**
  +     * Wrapper for OutputStream that will report all write
  +     * operations back to this class for file length calculations.
  +     */
  +    private static class CountingOutputStream extends OutputStream {
  +        private final OutputStream os;
  +        private final RollingFileAppender rfa;
  +
  +        public CountingOutputStream(final OutputStream os,
  +            final RollingFileAppender rfa) {
  +            this.os = os;
  +            this.rfa = rfa;
  +        }
  +
  +        public void close() throws IOException {
  +            os.close();
  +        }
  +
  +        public void flush() throws IOException {
  +            os.flush();
  +        }
  +
  +        public void write(final byte[] b) throws IOException {
  +            os.write(b);
  +            rfa.incrementFileLength(b.length);
  +        }
  +
  +        public void write(final byte[] b, final int off, final int len)
  +            throws IOException {
  +            os.write(b, off, len);
  +            rfa.incrementFileLength(len);
  +        }
  +
  +        public void write(final int b) throws IOException {
  +            os.write(b);
  +            rfa.incrementFileLength(1);
  +        }
       }
  -  }
   }
  
  
  
  1.10      +1 -1      
logging-log4j/src/java/org/apache/log4j/rolling/RollingPolicy.java
  
  Index: RollingPolicy.java
  ===================================================================
  RCS file: 
/home/cvs/logging-log4j/src/java/org/apache/log4j/rolling/RollingPolicy.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- RollingPolicy.java        23 Nov 2004 16:30:14 -0000      1.9
  +++ RollingPolicy.java        8 May 2005 03:43:40 -0000       1.10
  @@ -28,7 +28,7 @@
    * @author Ceki G&uuml;lc&uuml;
    * @since 1.3
    * */
  -public interface RollingPolicy extends OptionHandler {
  +public interface RollingPolicy {
     
     /**
      * Rolls over log files according to implementation policy.  
  
  
  
  1.3       +3 -1      
logging-log4j/src/java/org/apache/log4j/rolling/RollingPolicyBase.java
  
  Index: RollingPolicyBase.java
  ===================================================================
  RCS file: 
/home/cvs/logging-log4j/src/java/org/apache/log4j/rolling/RollingPolicyBase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RollingPolicyBase.java    6 Jan 2005 17:03:10 -0000       1.2
  +++ RollingPolicyBase.java    8 May 2005 03:43:40 -0000       1.3
  @@ -19,6 +19,7 @@
   import org.apache.log4j.rolling.helper.Compress;
   import org.apache.log4j.rolling.helper.FileNamePattern;
   import org.apache.log4j.spi.ComponentBase;
  +import org.apache.log4j.spi.OptionHandler;
   
   
   /**
  @@ -29,7 +30,8 @@
    * @author Ceki G&uuml;lc&uuml;
    * @since 1.3
    */
  -public abstract class RollingPolicyBase extends ComponentBase implements 
RollingPolicy {
  +public abstract class RollingPolicyBase extends ComponentBase
  +        implements RollingPolicy, OptionHandler {
     protected int compressionMode = Compress.NONE;
     protected FileNamePattern fileNamePattern;
     protected String fileNamePatternStr;
  
  
  
  1.10      +10 -4     
logging-log4j/src/java/org/apache/log4j/rolling/SizeBasedTriggeringPolicy.java
  
  Index: SizeBasedTriggeringPolicy.java
  ===================================================================
  RCS file: 
/home/cvs/logging-log4j/src/java/org/apache/log4j/rolling/SizeBasedTriggeringPolicy.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- SizeBasedTriggeringPolicy.java    8 Mar 2005 20:21:18 -0000       1.9
  +++ SizeBasedTriggeringPolicy.java    8 May 2005 03:43:40 -0000       1.10
  @@ -16,8 +16,10 @@
   
   package org.apache.log4j.rolling;
   
  -import java.io.File;
  +import org.apache.log4j.Appender;
   import org.apache.log4j.spi.LoggingEvent;
  +import org.apache.log4j.spi.OptionHandler;
  +import java.io.File;
   
   
   /**
  @@ -27,9 +29,10 @@
    * @author Ceki G&uuml;lc&uuml;
    *
    */
  -public class SizeBasedTriggeringPolicy implements TriggeringPolicy {
  +public class SizeBasedTriggeringPolicy implements TriggeringPolicy, 
OptionHandler {
     long maxFileSize = 10 * 1024 * 1024; // let 10 MB the default max size
   
  +
     public SizeBasedTriggeringPolicy() {
     }
   
  @@ -38,9 +41,12 @@
     }
   
   
  -  public boolean isTriggeringEvent(final File file, final LoggingEvent 
event) {
  +  public boolean isTriggeringEvent(final Appender appender,
  +                                   final LoggingEvent event,
  +                                   final File file,
  +                                   final long fileLength) {
       //System.out.println("Size"+file.length());
  -    return (file.length() >= maxFileSize);
  +    return (fileLength >= maxFileSize);
     }
   
     public long getMaxFileSize() {
  
  
  
  1.20      +6 -2      
logging-log4j/src/java/org/apache/log4j/rolling/TimeBasedRollingPolicy.java
  
  Index: TimeBasedRollingPolicy.java
  ===================================================================
  RCS file: 
/home/cvs/logging-log4j/src/java/org/apache/log4j/rolling/TimeBasedRollingPolicy.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- TimeBasedRollingPolicy.java       12 Feb 2005 03:10:27 -0000      1.19
  +++ TimeBasedRollingPolicy.java       8 May 2005 03:43:40 -0000       1.20
  @@ -22,9 +22,10 @@
   import org.apache.log4j.rolling.helper.RollingCalendar;
   import org.apache.log4j.rolling.helper.Util;
   import org.apache.log4j.spi.LoggingEvent;
  -import java.io.File;
  +import org.apache.log4j.Appender;
   
   import java.util.Date;
  +import java.io.File;
   
   
   /**
  @@ -256,7 +257,10 @@
       }
     }
   
  -  public boolean isTriggeringEvent(File file, final LoggingEvent event) {
  +  public boolean isTriggeringEvent(final Appender appender,
  +                                   final LoggingEvent event,
  +                                   final File file,
  +                                   final long fileLength) {
       //getLogger().debug("Is triggering event called");
       long n = System.currentTimeMillis();
   
  
  
  
  1.7       +21 -17    
logging-log4j/src/java/org/apache/log4j/rolling/TriggeringPolicy.java
  
  Index: TriggeringPolicy.java
  ===================================================================
  RCS file: 
/home/cvs/logging-log4j/src/java/org/apache/log4j/rolling/TriggeringPolicy.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TriggeringPolicy.java     12 Feb 2005 03:10:27 -0000      1.6
  +++ TriggeringPolicy.java     8 May 2005 03:43:40 -0000       1.7
  @@ -1,41 +1,45 @@
   /*
    * Copyright 1999,2005 The Apache Software Foundation.
  - * 
  + *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
  - * 
  + *
    *      http://www.apache.org/licenses/LICENSE-2.0
  - * 
  + *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
    */
  -
   package org.apache.log4j.rolling;
   
  -import java.io.File;
  +import org.apache.log4j.Appender;
   import org.apache.log4j.spi.LoggingEvent;
   import org.apache.log4j.spi.OptionHandler;
  +
  +import java.io.File;
  +
  +
   /**
    * A <code>TriggeringPolicy</code> controls the conditions under which 
rollover
  - * occurs. Such conditions include time od day, file size, an 
  + * occurs. Such conditions include time of day, file size, an
    * external event, the log request or a combination thereof.
    *
    * @author Ceki G&uuml;lc&uuml;
    * @since 1.3
    * */
  -
  -public interface TriggeringPolicy extends OptionHandler {
  -  
  -  /**
  -   * Should rolllover be triggered at this time?
  -   * 
  -   * @param file A reference to the currently active log file. 
  -   * @param event A reference to the currently event. 
  -   * @return true if a rollover should occur.
  -   */
  -  public boolean isTriggeringEvent(final File file, final LoggingEvent 
event);
  +public interface TriggeringPolicy {
  +    /**
  +     * Should rolllover be triggered at this time?
  +     *
  +     * @param appender A reference to the appender.
  +     * @param event A reference to the currently event.
  +     * @param file A reference to the currently active log file.
  +     * @param fileLength Length of the file in bytes.
  +     * @return true if a rollover should occur.
  +     */
  +    public boolean isTriggeringEvent(final Appender appender,
  +        final LoggingEvent event, final File file, final long fileLength);
   }
  
  
  
  1.12      +9 -19     
logging-log4j/tests/src/java/org/apache/log4j/rolling/SizeBasedRollingTest.java
  
  Index: SizeBasedRollingTest.java
  ===================================================================
  RCS file: 
/home/cvs/logging-log4j/tests/src/java/org/apache/log4j/rolling/SizeBasedRollingTest.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- SizeBasedRollingTest.java 8 Mar 2005 22:32:58 -0000       1.11
  +++ SizeBasedRollingTest.java 8 May 2005 03:43:41 -0000       1.12
  @@ -117,17 +117,12 @@
       assertTrue(new File("output/sizeBased-test2.0").exists());
       assertTrue(new File("output/sizeBased-test2.1").exists());
   
  -    // The File.length() method is not accurate under Windows
  -
  -     if(!isWindows()) {
  -
  -      assertTrue(Compare.compare("output/sizeBased-test2.log",
  -         "witness/rolling/sbr-test2.log"));
  -      assertTrue(Compare.compare("output/sizeBased-test2.0",
  -         "witness/rolling/sbr-test2.0"));
  -      assertTrue(Compare.compare("output/sizeBased-test2.1",
  -         "witness/rolling/sbr-test2.1"));
  -     }
  +    assertTrue(Compare.compare("output/sizeBased-test2.log",
  +     "witness/rolling/sbr-test2.log"));
  +    assertTrue(Compare.compare("output/sizeBased-test2.0",
  +     "witness/rolling/sbr-test2.0"));
  +    assertTrue(Compare.compare("output/sizeBased-test2.1",
  +     "witness/rolling/sbr-test2.1"));
     }
   
       /**
  @@ -165,14 +160,9 @@
       assertTrue(new File("output/sbr-test3.0.gz").exists());
       assertTrue(new File("output/sbr-test3.1.gz").exists());
   
  -     if(!isWindows()) {
  -
  -      assertTrue(Compare.compare("output/sbr-test3.log",  
"witness/rolling/sbr-test3.log"));
  -      assertTrue(Compare.gzCompare("output/sbr-test3.0.gz", 
"witness/rolling/sbr-test3.0.gz"));
  -      assertTrue(Compare.gzCompare("output/sbr-test3.1.gz", 
"witness/rolling/sbr-test3.1.gz"));
  -     }
  -
  -
  +    assertTrue(Compare.compare("output/sbr-test3.log",  
"witness/rolling/sbr-test3.log"));
  +    assertTrue(Compare.gzCompare("output/sbr-test3.0.gz", 
"witness/rolling/sbr-test3.0.gz"));
  +    assertTrue(Compare.gzCompare("output/sbr-test3.1.gz", 
"witness/rolling/sbr-test3.1.gz"));
     }
   
     boolean isWindows() {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to