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.varia; 019 020import org.apache.log4j.AppenderSkeleton; 021import org.apache.log4j.spi.LoggingEvent; 022 023/** 024 * A NullAppender merely exists, it never outputs a message to any 025 * device. 026 * @author Ceki Gülc¨ 027 */ 028public class NullAppender extends AppenderSkeleton { 029 030 private static NullAppender instance = new NullAppender(); 031 032 public NullAppender() { 033 } 034 035 /** 036 * There are no options to acticate. 037 * */ 038 public void activateOptions() { 039 } 040 041 /** 042 * Whenever you can, use this method to retreive an instance instead 043 * of instantiating a new one with <code>new</code>. 044 * @deprecated Use getNullAppender instead. getInstance should have been static. 045 * */ 046 public NullAppender getInstance() { 047 return instance; 048 } 049 050 /** 051 * Whenever you can, use this method to retreive an instance instead 052 * of instantiating a new one with <code>new</code>. 053 * */ 054 public static NullAppender getNullAppender() { 055 return instance; 056 } 057 058 public void close() { 059 } 060 061 /** 062 * Does not do anything. 063 * */ 064 public void doAppend(LoggingEvent event) { 065 } 066 067 /** 068 * Does not do anything. 069 * */ 070 protected void append(LoggingEvent event) { 071 } 072 073 /** 074 * NullAppenders do not need a layout. 075 * */ 076 public boolean requiresLayout() { 077 return false; 078 } 079}