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.spi.OptionHandler;
20  
21  
22  /***
23   * A <code>RollingPolicy</code> specifies the actions taken
24   * on a logging file rollover.
25   *
26   * @author Ceki G&uuml;lc&uuml;
27   * @author Curt Arnold
28   * */
29  public interface RollingPolicy extends OptionHandler {
30    /***
31     * Initialize the policy and return any initial actions for rolling file appender..
32     *
33     * @param file current value of RollingFileAppender.getFile().
34     * @param append current value of RollingFileAppender.getAppend().
35     * @return Description of the initialization, may be null to indicate
36     * no initialization needed.
37     * @throws SecurityException if denied access to log files.
38     */
39    public RolloverDescription initialize(
40      final String file, final boolean append) throws SecurityException;
41  
42    /***
43     * Prepare for a rollover.  This method is called prior to
44     * closing the active log file, performs any necessary
45     * preliminary actions and describes actions needed
46     * after close of current log file.
47     *
48     * @param activeFile file name for current active log file.
49     * @return Description of pending rollover, may be null to indicate no rollover
50     * at this time.
51     * @throws SecurityException if denied access to log files.
52     */
53    public RolloverDescription rollover(final String activeFile) throws SecurityException;
54  }