1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.log4j;
19
20 import org.apache.log4j.spi.OptionHandler;
21 import org.apache.log4j.spi.LoggingEvent;
22
23 /***
24 Extend this abstract class to create your own log layout format.
25
26 @author Ceki Gülcü
27
28 */
29
30 public abstract class Layout implements OptionHandler {
31
32
33
34 public final static String LINE_SEP = System.getProperty("line.separator");
35 public final static int LINE_SEP_LEN = LINE_SEP.length();
36
37
38 /***
39 Implement this method to create your own layout format.
40 */
41 abstract
42 public
43 String format(LoggingEvent event);
44
45 /***
46 Returns the content type output by this layout. The base class
47 returns "text/plain".
48 */
49 public
50 String getContentType() {
51 return "text/plain";
52 }
53
54 /***
55 Returns the header for the layout format. The base class returns
56 <code>null</code>. */
57 public
58 String getHeader() {
59 return null;
60 }
61
62 /***
63 Returns the footer for the layout format. The base class returns
64 <code>null</code>. */
65 public
66 String getFooter() {
67 return null;
68 }
69
70
71
72 /***
73 If the layout handles the throwable object contained within
74 {@link LoggingEvent}, then the layout should return
75 <code>false</code>. Otherwise, if the layout ignores throwable
76 object, then the layout should return <code>true</code>.
77
78 <p>The {@link SimpleLayout}, {@link TTCCLayout}, {@link
79 PatternLayout} all return <code>true</code>. The {@link
80 org.apache.log4j.xml.XMLLayout} returns <code>false</code>.
81
82 @since 0.8.4 */
83 abstract
84 public
85 boolean ignoresThrowable();
86
87 }