View Javadoc

1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2009, QOS.ch. All rights reserved.
4    *
5    * This program and the accompanying materials are dual-licensed under
6    * either the terms of the Eclipse Public License v1.0 as published by
7    * the Eclipse Foundation
8    *
9    *   or (per the licensee's choosing)
10   *
11   * under the terms of the GNU Lesser General Public License version 2.1
12   * as published by the Free Software Foundation.
13   */
14  package ch.qos.logback.core.rolling;
15  
16  import ch.qos.logback.core.FileAppender;
17  import ch.qos.logback.core.rolling.helper.CompressionMode;
18  import ch.qos.logback.core.spi.LifeCycle;
19  
20  /**
21   * A <code>RollingPolicy</code> is responsible for performing the rolling over
22   * of the active log file. The <code>RollingPolicy</code> is also responsible
23   * for providing the <em>active log file</em>, that is the live file where
24   * logging output will be directed.
25   * 
26   * @author Ceki G&uuml;lc&uuml;
27   */
28  public interface RollingPolicy extends LifeCycle {
29  
30    /**
31     * Rolls over log files according to implementation policy.
32     * 
33     * <p>This method is invoked by {@link RollingFileAppender}, usually at the
34     * behest of its {@link TriggeringPolicy}.
35     * 
36     * @throws RolloverFailure
37     *                 Thrown if the rollover operation fails for any reason.
38     */
39    public void rollover() throws RolloverFailure;
40  
41    /**
42     * Get the name of the active log file.
43     * 
44     * <p>With implementations such as {@link TimeBasedRollingPolicy}, this
45     * method returns a new file name, where the actual output will be sent.
46     * 
47     * <p>On other implementations, this method might return the FileAppender's
48     * file property.
49     */
50    public String getActiveFileName();
51  
52    /**
53     * The compression mode for this policy.
54     * 
55     * @return
56     */
57    public CompressionMode getCompressionMode();
58    
59    /**
60     * This method allows RollingPolicy implementations to be aware of their
61     * containing appender.
62     * 
63     * @param appender
64     */
65  
66    public void setParent(FileAppender appender);
67  }