Log4j 1.3alpha-5

org.apache.log4j
Class Layout

java.lang.Object
  |
  +--org.apache.log4j.spi.ComponentBase
        |
        +--org.apache.log4j.Layout
All Implemented Interfaces:
Component, OptionHandler
Direct Known Subclasses:
PatternLayout, SimpleLayout, TTCCLayout, XMLLayout

public abstract class Layout
extends ComponentBase
implements OptionHandler

Extend this abstract class to create your own log layout format.

Author:
Ceki Gülcü, Chris Nokes

Field Summary
 java.io.CharArrayWriter charArrayWriter
           
protected  boolean ignoresThrowable
           
static java.lang.String LINE_SEP
           
static int LINE_SEP_LEN
           
 
Fields inherited from class org.apache.log4j.spi.ComponentBase
repository
 
Constructor Summary
Layout()
           
 
Method Summary
 java.lang.String format(LoggingEvent event)
          Implement this method to create your own layout format.
abstract  void format(java.io.Writer output, LoggingEvent event)
           
 java.lang.String getContentType()
          Returns the content type output by this layout.
 java.lang.String getFooter()
          Returns the footer for the layout format.
 java.lang.String getHeader()
          Returns the header for the layout format.
 boolean ignoresThrowable()
          If the layout handles the throwable object contained within LoggingEvent, then the layout should return false.
 void setFooter(java.lang.String footer)
          Set the footer.
 void setHeader(java.lang.String header)
          Set the header.
 void setIgnoresThrowable(boolean ignoresThrowable)
           
 
Methods inherited from class org.apache.log4j.spi.ComponentBase
getLogger, setLoggerRepository
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.log4j.spi.OptionHandler
activateOptions
 

Field Detail

LINE_SEP

public static final java.lang.String LINE_SEP

LINE_SEP_LEN

public static final int LINE_SEP_LEN

charArrayWriter

public java.io.CharArrayWriter charArrayWriter

ignoresThrowable

protected boolean ignoresThrowable
Constructor Detail

Layout

public Layout()
Method Detail

format

public java.lang.String format(LoggingEvent event)
Implement this method to create your own layout format.


format

public abstract void format(java.io.Writer output,
                            LoggingEvent event)
                     throws java.io.IOException
java.io.IOException

getContentType

public java.lang.String getContentType()
Returns the content type output by this layout. The base class returns "text/plain".


getHeader

public java.lang.String getHeader()
Returns the header for the layout format. There is no default header.


getFooter

public java.lang.String getFooter()
Returns the footer for the layout format. There is no default footer.


ignoresThrowable

public boolean ignoresThrowable()
If the layout handles the throwable object contained within LoggingEvent, then the layout should return false. Otherwise, if the layout ignores throwable object, then the layout should return true.

By default, SimpleLayout, TTCCLayout, PatternLayout all return true. The XMLLayout returns false.

As of log4j version 1.3, ignoresThrowable is a settable property. Thus, you can override a layout's default setting.

Since:
0.8.4

setIgnoresThrowable

public void setIgnoresThrowable(boolean ignoresThrowable)
Parameters:
ignoresThrowable -
Since:
1.3

setFooter

public void setFooter(java.lang.String footer)
Set the footer. Note that some layout have their own footers and may choose to ignote the footer set here.

Parameters:
footer - the footer
Since:
1.3

setHeader

public void setHeader(java.lang.String header)
Set the header. Note that some layout have their own headers and may choose to ignote the header set here.

Parameters:
header - the header
Since:
1.3

Log4j 1.3alpha-5

Copyright 2000-2005 Apache Software Foundation.