View Javadoc

1   /*
2    * Copyright 1999,2005 The Apache Software Foundation.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.apache.log4j.rolling;
18  
19  import org.apache.log4j.Appender;
20  import org.apache.log4j.spi.LoggingEvent;
21  import org.apache.log4j.spi.OptionHandler;
22  
23  
24  /***
25   * A <code>TriggeringPolicy</code> controls the conditions under which rollover
26   * occurs. Such conditions include time of day, file size, an
27   * external event, the log request or a combination thereof.
28   *
29   * @author Ceki G&uuml;lc&uuml;
30   * @author Curt Arnold
31   * 
32   */
33  public interface TriggeringPolicy extends OptionHandler {
34    /***
35     * Determines if a rollover may be appropriate at this time.  If
36     * true is returned, RolloverPolicy.rollover will be called but it
37     * can determine that a rollover is not warranted.
38     *
39     * @param appender A reference to the appender.
40     * @param event A reference to the currently event.
41     * @param filename The filename for the currently active log file.
42     * @param fileLength Length of the file in bytes.
43     * @return true if a rollover should occur.
44     */
45    public boolean isTriggeringEvent(
46      final Appender appender, final LoggingEvent event, final String filename,
47      final long fileLength);
48  }