log4j Tutorial - Log4j Log Format

Apache log4j provides Layout objects to format logging data according to various layouts.

The top-level class in the hierarchy of layout classes is the abstract class org.apache.log4j.Layout.

org.apache.log4j.Layout is the base class for all other Layout classes in the log4j API.

It has the following subclasses.

  • DateLayout

  • HTMLLayout

  • PatternLayout.

  • SimpleLayout

  • XMLLayout

Methods from Layout class

The following table lists the classes from Layout class.

public abstract boolean ignoresThrowable()If to ignore the Throwable object.
public abstract String format(LoggingEvent event)implement this method to do layout for formatting.
public String getContentType()Returns the content type used by the Layout objects.
public String getFooter()footer information of the logging message.
public String getHeader()header information of the logging message.