001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018package org.apache.log4j; 019 020import org.apache.log4j.spi.Filter; 021import org.apache.log4j.spi.ErrorHandler; 022import org.apache.log4j.spi.LoggingEvent; 023 024/** 025 Implement this interface for your own strategies for outputting log 026 statements. 027 028 @author Ceki Gülcü 029*/ 030public interface Appender { 031 032 /** 033 Add a filter to the end of the filter list. 034 035 @since 0.9.0 036 */ 037 void addFilter(Filter newFilter); 038 039 /** 040 Returns the head Filter. The Filters are organized in a linked list 041 and so all Filters on this Appender are available through the result. 042 043 @return the head Filter or null, if no Filters are present 044 @since 1.1 045 */ 046 public 047 Filter getFilter(); 048 049 /** 050 Clear the list of filters by removing all the filters in it. 051 052 @since 0.9.0 053 */ 054 public 055 void clearFilters(); 056 057 /** 058 Release any resources allocated within the appender such as file 059 handles, network connections, etc. 060 061 <p>It is a programming error to append to a closed appender. 062 063 @since 0.8.4 064 */ 065 public 066 void close(); 067 068 /** 069 Log in <code>Appender</code> specific way. When appropriate, 070 Loggers will call the <code>doAppend</code> method of appender 071 implementations in order to log. */ 072 public 073 void doAppend(LoggingEvent event); 074 075 076 /** 077 Get the name of this appender. 078 @return name, may be null.*/ 079 public 080 String getName(); 081 082 083 /** 084 Set the {@link ErrorHandler} for this appender. 085 086 @since 0.9.0 087 */ 088 public 089 void setErrorHandler(ErrorHandler errorHandler); 090 091 /** 092 Returns the {@link ErrorHandler} for this appender. 093 094 @since 1.1 095 */ 096 public 097 ErrorHandler getErrorHandler(); 098 099 /** 100 Set the {@link Layout} for this appender. 101 102 @since 0.8.1 103 */ 104 public 105 void setLayout(Layout layout); 106 107 /** 108 Returns this appenders layout. 109 110 @since 1.1 111 */ 112 public 113 Layout getLayout(); 114 115 116 /** 117 Set the name of this appender. The name is used by other 118 components to identify this appender. 119 120 @since 0.8.1 121 */ 122 public 123 void setName(String name); 124 125 /** 126 Configurators call this method to determine if the appender 127 requires a layout. If this method returns <code>true</code>, 128 meaning that layout is required, then the configurator will 129 configure an layout using the configuration information at its 130 disposal. If this method returns <code>false</code>, meaning that 131 a layout is not required, then layout configuration will be 132 skipped even if there is available layout configuration 133 information at the disposal of the configurator.. 134 135 <p>In the rather exceptional case, where the appender 136 implementation admits a layout but can also work without it, then 137 the appender should return <code>true</code>. 138 139 @since 0.8.4 */ 140 public 141 boolean requiresLayout(); 142}