KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > log4j > performance > NullAppender


1 /*
2  * Copyright 1999-2005 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.performance;
18
19 import org.apache.log4j.Layout;
20 import org.apache.log4j.spi.LoggingEvent;
21 import org.apache.log4j.AppenderSkeleton;
22
23 /**
24  * A bogus appender which calls the format method of its layout object
25  * but does not write the result anywhere.
26  *
27  * <p><b> <font color="#FF2222">The
28  * <code>org.apache.log4j.performance.NullAppender</code> class is
29  * intended for internal use only.</font> Consequently, it is not
30  * included in the <em>log4j.jar</em> file.</b> </p>
31  * */

32 public class NullAppender extends AppenderSkeleton {
33
34   public static String JavaDoc s;
35   public String JavaDoc t;
36
37   public
38   NullAppender() {}
39
40   public
41   NullAppender(Layout layout) {
42     this.layout = layout;
43   }
44
45   public
46   void close() {}
47
48   public
49   void doAppend(LoggingEvent event) {
50     if(layout != null) {
51       t = layout.format(event);
52       s = t;
53     }
54   }
55
56   public
57   void append(LoggingEvent event) {
58   }
59
60   /**
61      This is a bogus appender but it still uses a layout.
62   */

63   public
64   boolean requiresLayout() {
65     return true;
66   }
67 }
68
Popular Tags