Package org.apache.log4j
Class HTMLLayout
- java.lang.Object
-
- org.apache.log4j.Layout
-
- org.apache.log4j.HTMLLayout
-
- All Implemented Interfaces:
OptionHandler
public class HTMLLayout extends Layout
This layout outputs events in a HTML table. Appenders using this layout should have their encoding set to UTF-8 or UTF-16, otherwise events containing non ASCII characters could result in corrupted log files.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
BUF_SIZE
static java.lang.String
LOCATION_INFO_OPTION
Deprecated.Options are now handled using the JavaBeans paradigm.(package private) boolean
locationInfo
protected int
MAX_CAPACITY
private java.lang.StringBuffer
sbuf
(package private) java.lang.String
title
static java.lang.String
TITLE_OPTION
A string constant used in naming the option for setting the the HTML document title.(package private) static java.lang.String
TRACE_PREFIX
-
Fields inherited from class org.apache.log4j.Layout
LINE_SEP, LINE_SEP_LEN
-
-
Constructor Summary
Constructors Constructor Description HTMLLayout()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activateOptions()
No options to activate.(package private) void
appendThrowableAsHTML(java.lang.String[] s, java.lang.StringBuffer sbuf)
java.lang.String
format(LoggingEvent event)
Implement this method to create your own layout format.java.lang.String
getContentType()
Returns the content type output by this layout, i.e "text/html".java.lang.String
getFooter()
Returns the appropriate HTML footers.java.lang.String
getHeader()
Returns appropriate HTML headers.boolean
getLocationInfo()
Returns the current value of the LocationInfo option.java.lang.String
getTitle()
Returns the current value of the Title option.boolean
ignoresThrowable()
The HTML layout handles the throwable contained in logging events.void
setLocationInfo(boolean flag)
The LocationInfo option takes a boolean value.void
setTitle(java.lang.String title)
The Title option takes a String value.
-
-
-
Field Detail
-
BUF_SIZE
protected final int BUF_SIZE
- See Also:
- Constant Field Values
-
MAX_CAPACITY
protected final int MAX_CAPACITY
- See Also:
- Constant Field Values
-
TRACE_PREFIX
static java.lang.String TRACE_PREFIX
-
sbuf
private java.lang.StringBuffer sbuf
-
LOCATION_INFO_OPTION
public static final java.lang.String LOCATION_INFO_OPTION
Deprecated.Options are now handled using the JavaBeans paradigm. This constant is not longer needed and will be removed in the near term.A string constant used in naming the option for setting the the location information flag. Current value of this string constant is LocationInfo.Note that all option keys are case sensitive.
- See Also:
- Constant Field Values
-
TITLE_OPTION
public static final java.lang.String TITLE_OPTION
A string constant used in naming the option for setting the the HTML document title. Current value of this string constant is Title.- See Also:
- Constant Field Values
-
locationInfo
boolean locationInfo
-
title
java.lang.String title
-
-
Method Detail
-
setLocationInfo
public void setLocationInfo(boolean flag)
The LocationInfo option takes a boolean value. By default, it is set to false which means there will be no location information output by this layout. If the the option is set to true, then the file name and line number of the statement at the origin of the log statement will be output.If you are embedding this layout within an
SMTPAppender
then make sure to set the LocationInfo option of that appender as well.
-
getLocationInfo
public boolean getLocationInfo()
Returns the current value of the LocationInfo option.
-
setTitle
public void setTitle(java.lang.String title)
The Title option takes a String value. This option sets the document title of the generated HTML document.Defaults to 'Log4J Log Messages'.
-
getTitle
public java.lang.String getTitle()
Returns the current value of the Title option.
-
getContentType
public java.lang.String getContentType()
Returns the content type output by this layout, i.e "text/html".- Overrides:
getContentType
in classLayout
-
activateOptions
public void activateOptions()
No options to activate.
-
format
public java.lang.String format(LoggingEvent event)
Description copied from class:Layout
Implement this method to create your own layout format.
-
appendThrowableAsHTML
void appendThrowableAsHTML(java.lang.String[] s, java.lang.StringBuffer sbuf)
-
getHeader
public java.lang.String getHeader()
Returns appropriate HTML headers.
-
getFooter
public java.lang.String getFooter()
Returns the appropriate HTML footers.
-
ignoresThrowable
public boolean ignoresThrowable()
The HTML layout handles the throwable contained in logging events. Hence, this method returnfalse
.- Specified by:
ignoresThrowable
in classLayout
-
-