1/*2 * Licensed to the Apache Software Foundation (ASF) under one or more3 * contributor license agreements. See the NOTICE file distributed with4 * this work for additional information regarding copyright ownership.5 * The ASF licenses this file to You under the Apache license, Version 2.06 * (the "License"); you may not use this file except in compliance with7 * the License. You may obtain a copy of the License at8 *9 * http://www.apache.org/licenses/LICENSE-2.010 *11 * Unless required by applicable law or agreed to in writing, software12 * distributed under the License is distributed on an "AS IS" BASIS,13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14 * See the license for the specific language governing permissions and15 * limitations under the license.16 */17package org.apache.logging.log4j.core;
1819import java.io.Serializable;
2021/**22 * Appends {@link LogEvent}s. An Appender can contain a {@link Layout} if applicable as well23 * as an {@link ErrorHandler}. Typical Appender implementations coordinate with an24 * implementation of {@link org.apache.logging.log4j.core.appender.AbstractManager} to handle external resources25 * such as streams, connections, and other shared state. As Appenders are plugins, concrete implementations need to26 * be annotated with {@link org.apache.logging.log4j.core.config.plugins.Plugin} and need to provide a static27 * factory method annotated with {@link org.apache.logging.log4j.core.config.plugins.PluginFactory}.28 *29 * <p>Most core plugins are written using a related Manager class that handle the actual task of serializing a30 * {@link LogEvent} to some output location. For instance, many Appenders can take31 * advantage of the {@link org.apache.logging.log4j.core.appender.OutputStreamManager} class.</p>32 *33 * <p>It is recommended that Appenders don't do any heavy lifting since there can be many instances of the class34 * being used at any given time. When resources require locking (e.g., through {@link java.nio.channels.FileLock}),35 * it is important to isolate synchronized code to prevent concurrency issues.</p>36 */37publicinterfaceAppenderextendsLifeCycle {
3839/**40 * Logs a LogEvent using whatever logic this Appender wishes to use. It is typically recommended to use a41 * bridge pattern not only for the benefits from decoupling an Appender from its implementation, but it is also42 * handy for sharing resources which may require some form of locking.43 *44 * @param event The LogEvent.45 */46void append(LogEvent event);
474849/**50 * Get the name of this Appender.51 *52 * @return name, may be null.53 */54 String getName();
5556/**57 * Returns the Layout used by this Appender if applicable.58 *59 * @return the Layout for this Appender or {@code null} if none is configured.60 */61 Layout<? extends Serializable> getLayout();
6263/**64 * Some Appenders need to propagate exceptions back to the application. When {@code ignoreExceptions} is65 * {@code false} the AppenderControl will allow the exception to percolate.66 *67 * @return {@code true} if exceptions will be logged but not thrown, {@code false} otherwise.68 */69boolean ignoreExceptions();
7071/**72 * Gets the {@link ErrorHandler} used for handling exceptions.73 *74 * @return the ErrorHandler for handling exceptions.75 */76ErrorHandler getHandler();
7778/**79 * Sets the {@link ErrorHandler} used for handling exceptions.80 *81 * @param handler the ErrorHandler to use for handling exceptions.82 */83void setHandler(ErrorHandler handler);
84 }