• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2001-2004 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;
18 
19 import org.apache.log4j.spi.Filter;
20 import org.apache.log4j.spi.ErrorHandler;
21 import org.apache.log4j.spi.Layout;
22 import org.apache.log4j.spi.LoggingEvent;
23 
24 /**
25  * Implement this interface for your own strategies for outputting log
26  * statements.
27  *
28  * @author Ceki Gülcü
29  */
30 public interface Appender {
31 
32     /**
33      * Add a filter to the end of the filter list.
34      *
35      * @since 0.9.0
36      */
addFilter(Filter newFilter)37     void addFilter(Filter newFilter);
38 
39     /**
40      * Returns the head Filter. The Filters are organized in a linked list
41      * and so all Filters on this Appender are available through the result.
42      *
43      * @return the head Filter or null, if no Filters are present
44      * @since 1.1
45      */
getFilter()46     public Filter getFilter();
47 
48     /**
49      * Clear the list of filters by removing all the filters in it.
50      *
51      * @since 0.9.0
52      */
clearFilters()53     public void clearFilters();
54 
55     /**
56      * Release any resources allocated within the appender such as file
57      * handles, network connections, etc.
58      * <p/>
59      * <p>It is a programming error to append to a closed appender.
60      *
61      * @since 0.8.4
62      */
close()63     public void close();
64 
65     /**
66      * Log in <code>Appender</code> specific way. When appropriate,
67      * Loggers will call the <code>doAppend</code> method of appender
68      * implementations in order to log.
69      */
doAppend(LoggingEvent event)70     public void doAppend(LoggingEvent event);
71 
72     /**
73      * Get the name of this appender. The name uniquely identifies the
74      * appender.
75      */
getName()76     public String getName();
77 
78     /**
79      * Set the {@link ErrorHandler} for this appender.
80      *
81      * @since 0.9.0
82      */
setErrorHandler(ErrorHandler errorHandler)83     public void setErrorHandler(ErrorHandler errorHandler);
84 
85     /**
86      * Returns the {@link ErrorHandler} for this appender.
87      *
88      * @since 1.1
89      */
getErrorHandler()90     public ErrorHandler getErrorHandler();
91 
92     /**
93      * Set the {@link Layout} for this appender.
94      *
95      * @since 0.8.1
96      */
setLayout(Layout layout)97     public void setLayout(Layout layout);
98 
99     /**
100      * Returns this appenders layout.
101      *
102      * @since 1.1
103      */
getLayout()104     public Layout getLayout();
105 
106     /**
107      * Set the name of this appender. The name is used by other
108      * components to identify this appender.
109      *
110      * @since 0.8.1
111      */
setName(String name)112     public void setName(String name);
113 
114     /**
115      * Configurators call this method to determine if the appender
116      * requires a layout. If this method returns <code>true</code>,
117      * meaning that layout is required, then the configurator will
118      * configure an layout using the configuration information at its
119      * disposal.  If this method returns <code>false</code>, meaning that
120      * a layout is not required, then layout configuration will be
121      * skipped even if there is available layout configuration
122      * information at the disposal of the configurator..
123      * <p/>
124      * <p>In the rather exceptional case, where the appender
125      * implementation admits a layout but can also work without it, then
126      * the appender should return <code>true</code>.
127      *
128      * @since 0.8.4
129      */
requiresLayout()130     public boolean requiresLayout();
131 }
132