Log4j 1.3alpha-8

org.apache.log4j
Class HTMLLayout

java.lang.Object
  |
  +--org.apache.log4j.spi.ComponentBase
        |
        +--org.apache.log4j.Layout
              |
              +--org.apache.log4j.HTMLLayout
All Implemented Interfaces:
Component, OptionHandler

public class HTMLLayout
extends Layout

HTMLLayout outputs events in an HTML table. The content of the table columns are specified using a conversion pattern. See PatternLayout for documentation on the available patterns.

Author:
Ceki Gülcü, Steve Mactaggart

Field Summary
protected  int BUF_SIZE
           
static 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.
protected  int MAX_CAPACITY
           
static String TITLE_OPTION
          Deprecated. Options are now handled using the JavaBeans paradigm. This constant is not longer needed and will be removed in the near term.
 
Fields inherited from class org.apache.log4j.Layout
ignoresThrowable, LINE_SEP, LINE_SEP_LEN
 
Fields inherited from class org.apache.log4j.spi.ComponentBase
repository
 
Constructor Summary
HTMLLayout()
          Constructs a PatternLayout using the DEFAULT_LAYOUT_PATTERN.
HTMLLayout(String pattern)
          Constructs a PatternLayout using the supplied conversion pattern.
 
Method Summary
 void activateOptions()
          Does not do anything as options become effective
 String format(LoggingEvent event)
          {@inheritDoc}
 String getContentType()
          Returns the content type output by this layout, i.e "text/html".
 String getConversionPattern()
          Returns the value of the ConversionPattern option.
 String getFooter()
          Returns the appropriate HTML footers.
 String getHeader()
          Returns appropriate HTML headers.
 boolean getLocationInfo()
          Returns the current value of the LocationInfo option.
 String getTitle()
          Returns the current value of the Title option.
 String getURL2ExternalCSS()
          Return the URL to the external CSS file.
 boolean ignoresThrowable()
          The HTML layout handles the throwable contained in logging events.
 boolean isInternalCSS()
          Returns the value of the internalCSS option.
 void setConversionPattern(String conversionPattern)
          Set the ConversionPattern option.
 void setInternalCSS(boolean internalCSS)
          Set the value of the internalCSS option.
 void setLocationInfo(boolean flag)
          The LocationInfo option takes a boolean value.
 void setTitle(String title)
          The Title option takes a String value.
 void setURL2ExternalCSS(String url2ExternalCSS)
          Set the URL for the external CSS file.
 
Methods inherited from class org.apache.log4j.Layout
setFooter, setHeader, setIgnoresThrowable
 
Methods inherited from class org.apache.log4j.spi.ComponentBase
getLogger, getLoggerRepository, getNonFloodingLogger, resetErrorCount, setLoggerRepository
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCATION_INFO_OPTION

public static final 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.


TITLE_OPTION

public static final String TITLE_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 HTML document title. Current value of this string constant is Title.

BUF_SIZE

protected final int BUF_SIZE

MAX_CAPACITY

protected final int MAX_CAPACITY
Constructor Detail

HTMLLayout

public HTMLLayout()
Constructs a PatternLayout using the DEFAULT_LAYOUT_PATTERN. The default pattern just produces the application supplied message.

HTMLLayout

public HTMLLayout(String pattern)
Constructs a PatternLayout using the supplied conversion pattern.
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.

setConversionPattern

public void setConversionPattern(String conversionPattern)
Set the ConversionPattern option. This is the string which controls formatting and consists of a mix of literal content and conversion specifiers.

getConversionPattern

public String getConversionPattern()
Returns the value of the ConversionPattern option.

activateOptions

public void activateOptions()
Does not do anything as options become effective

setTitle

public void setTitle(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 String getTitle()
Returns the current value of the Title option.

isInternalCSS

public boolean isInternalCSS()
Returns the value of the internalCSS option. See setInternalCSS(boolean) method for details about the meaning of this option.
Returns:
boolean Value of internalCSS option

setInternalCSS

public void setInternalCSS(boolean internalCSS)
Set the value of the internalCSS option. If set to true, the generated HTML ouput will include an internal cascading style sheet. Otherwise, the generated HTML output will include a reference to an external CSS.

By default, internalCSS value is set to false, that is, by default, only a link to an external CSS file will be generated.

Parameters:
internalCSS -  
See Also:
setURL2ExternalCSS(java.lang.String)

getURL2ExternalCSS

public String getURL2ExternalCSS()
Return the URL to the external CSS file. See setURL2ExternalCSS(java.lang.String) method for details about the meaning of this option.
Returns:
URL to the external CSS file.

setURL2ExternalCSS

public void setURL2ExternalCSS(String url2ExternalCSS)
Set the URL for the external CSS file. By default, the external CSS file is set to "http://logging.apache.org/log4j/docs/css/eventTable-1.0.css".

getContentType

public String getContentType()
Returns the content type output by this layout, i.e "text/html".
Overrides:
getContentType in class Layout

getHeader

public String getHeader()
Returns appropriate HTML headers.
Overrides:
getHeader in class Layout

getFooter

public String getFooter()
Returns the appropriate HTML footers.
Overrides:
getFooter in class Layout

ignoresThrowable

public boolean ignoresThrowable()
The HTML layout handles the throwable contained in logging events. Hence, this method return false.
Overrides:
ignoresThrowable in class Layout

format

public String format(LoggingEvent event)
{@inheritDoc}
Overrides:
format in class Layout

Log4j 1.3alpha-8

Copyright © 2000-2006 Apache Software Foundation.
Licensed under the Apache License, Version 2.0.