org.riotfamily.common.log
Class FreeMarkerLayout

java.lang.Object
  extended by org.apache.log4j.Layout
      extended by org.riotfamily.common.log.FreeMarkerLayout
All Implemented Interfaces:
org.apache.log4j.spi.OptionHandler

public class FreeMarkerLayout
extends org.apache.log4j.Layout

Log4J Layout that uses a FreeMarker template to do the formatting.

The actual formatting is deferred until getFooter() is invoked, therefore this layout is only suitable for certain appenders like the SmartSmtpAppender.

Since:
8.0
Author:
Felix Gnass [fgnass at neteye dot de]

Nested Class Summary
static class FreeMarkerLayout.MacroHelper
           
 
Field Summary
 
Fields inherited from class org.apache.log4j.Layout
LINE_SEP, LINE_SEP_LEN
 
Constructor Summary
FreeMarkerLayout()
           
 
Method Summary
 void activateOptions()
           
 String format(org.apache.log4j.spi.LoggingEvent event)
          Adds the event to the model for later processing and returns an empty String.
 String getContentType()
           
 String getFooter()
          Processes the template and returns the formatted output.
 String getHeader()
          (Re-)initializes the model map.
 boolean ignoresThrowable()
           
 void setContentType(String contentType)
          Sets the contentType that will be returned by getContentType().
 void setTemplate(String templateName)
          Sets the location in the classpath of the template to use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FreeMarkerLayout

public FreeMarkerLayout()
Method Detail

setContentType

public void setContentType(String contentType)
Sets the contentType that will be returned by getContentType(). Default is text/html.


setTemplate

public void setTemplate(String templateName)
Sets the location in the classpath of the template to use. The default is /org/riotfamily/common/log/layout.ftl.


activateOptions

public void activateOptions()

getContentType

public String getContentType()
Overrides:
getContentType in class org.apache.log4j.Layout

getHeader

public String getHeader()
(Re-)initializes the model map. The method always returns null.

Overrides:
getHeader in class org.apache.log4j.Layout

format

public String format(org.apache.log4j.spi.LoggingEvent event)
Adds the event to the model for later processing and returns an empty String.

Specified by:
format in class org.apache.log4j.Layout

getFooter

public String getFooter()
Processes the template and returns the formatted output.

Overrides:
getFooter in class org.apache.log4j.Layout

ignoresThrowable

public boolean ignoresThrowable()
Specified by:
ignoresThrowable in class org.apache.log4j.Layout