KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > log4j > Layout


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;
18
19 import org.apache.log4j.spi.OptionHandler;
20 import org.apache.log4j.spi.LoggingEvent;
21
22 /**
23    Extend this abstract class to create your own log layout format.
24    
25    @author Ceki Gülcü
26
27 */

28   
29 public abstract class Layout implements OptionHandler {
30
31   // Note that the line.separator property can be looked up even by
32
// applets.
33
public final static String JavaDoc LINE_SEP = System.getProperty("line.separator");
34   public final static int LINE_SEP_LEN = LINE_SEP.length();
35
36
37   /**
38      Implement this method to create your own layout format.
39   */

40   abstract
41   public
42   String JavaDoc format(LoggingEvent event);
43
44   /**
45      Returns the content type output by this layout. The base class
46      returns "text/plain".
47   */

48   public
49   String JavaDoc getContentType() {
50     return "text/plain";
51   }
52
53   /**
54      Returns the header for the layout format. The base class returns
55      <code>null</code>. */

56   public
57   String JavaDoc getHeader() {
58     return null;
59   }
60
61   /**
62      Returns the footer for the layout format. The base class returns
63      <code>null</code>. */

64   public
65   String JavaDoc getFooter() {
66     return null;
67   }
68
69
70
71   /**
72      If the layout handles the throwable object contained within
73      {@link LoggingEvent}, then the layout should return
74      <code>false</code>. Otherwise, if the layout ignores throwable
75      object, then the layout should return <code>true</code>.
76
77      <p>The {@link SimpleLayout}, {@link TTCCLayout}, {@link
78      PatternLayout} all return <code>true</code>. The {@link
79      org.apache.log4j.xml.XMLLayout} returns <code>false</code>.
80
81      @since 0.8.4 */

82   abstract
83   public
84   boolean ignoresThrowable();
85
86 }
87
Popular Tags