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 package org.apache.log4j; 018 019 import org.apache.log4j.spi.Filter; 020 import org.apache.log4j.spi.ErrorHandler; 021 import org.apache.log4j.spi.LoggingEvent; 022 023 /** 024 * Implement this interface for your own strategies for outputting log 025 * statements. 026 * 027 * @author Ceki Gülcü 028 */ 029 public interface Appender { 030 031 /** 032 * Add a filter to the end of the filter list. 033 * 034 * @since 0.9.0 035 */ 036 void addFilter(Filter newFilter); 037 038 /** 039 * Returns the head Filter. The Filters are organized in a linked list 040 * and so all Filters on this Appender are available through the result. 041 * 042 * @return the head Filter or null, if no Filters are present 043 * @since 1.1 044 */ 045 public Filter getFilter(); 046 047 /** 048 * Clear the list of filters by removing all the filters in it. 049 * 050 * @since 0.9.0 051 */ 052 public void clearFilters(); 053 054 /** 055 * Release any resources allocated within the appender such as file 056 * handles, network connections, etc. 057 * <p/> 058 * <p>It is a programming error to append to a closed appender. 059 * 060 * @since 0.8.4 061 */ 062 public void close(); 063 064 /** 065 * Log in <code>Appender</code> specific way. When appropriate, 066 * Loggers will call the <code>doAppend</code> method of appender 067 * implementations in order to log. 068 */ 069 public void doAppend(LoggingEvent event); 070 071 072 /** 073 * Get the name of this appender. 074 * 075 * @return name, may be null. 076 */ 077 public String getName(); 078 079 080 /** 081 * Set the {@link ErrorHandler} for this appender. 082 * 083 * @since 0.9.0 084 */ 085 public void setErrorHandler(ErrorHandler errorHandler); 086 087 /** 088 * Returns the {@link ErrorHandler} for this appender. 089 * 090 * @since 1.1 091 */ 092 public ErrorHandler getErrorHandler(); 093 094 /** 095 * Set the {@link Layout} for this appender. 096 * 097 * @since 0.8.1 098 */ 099 public void setLayout(Layout layout); 100 101 /** 102 * Returns this appenders layout. 103 * 104 * @since 1.1 105 */ 106 public Layout getLayout(); 107 108 109 /** 110 * Set the name of this appender. The name is used by other 111 * components to identify this appender. 112 * 113 * @since 0.8.1 114 */ 115 public void setName(String name); 116 117 /** 118 * Configurators call this method to determine if the appender 119 * requires a layout. If this method returns {@code true}, 120 * meaning that layout is required, then the configurator will 121 * configure an layout using the configuration information at its 122 * disposal. If this method returns {@code false}, meaning that 123 * a layout is not required, then layout configuration will be 124 * skipped even if there is available layout configuration 125 * information at the disposal of the configurator.. 126 * <p/> 127 * <p>In the rather exceptional case, where the appender 128 * implementation admits a layout but can also work without it, then 129 * the appender should return {@code true}. 130 * 131 * @since 0.8.4 132 */ 133 public boolean requiresLayout(); 134 } 135