org.apache.mina.util
Class Log4jXmlFormatter

java.lang.Object
  extended by java.util.logging.Formatter
      extended by org.apache.mina.util.Log4jXmlFormatter

public class Log4jXmlFormatter
extends Formatter

Implementation of Formatter that generates xml in the log4j format.

The generated xml corresponds 100% with what is generated by log4j's XMLLayout

The MDC properties will only be correct when format is called from the same thread that generated the LogRecord.

The file and line attributes in the locationInfo element will always be "?" since java.util.logging.LogRecord does not provide that info.

The implementation is heavily based on org.apache.log4j.xml.XMLLayout

Version:
$Rev: 662908 $, $Date: 2008-06-04 00:37:22 +0200 (mer, 04 jun 2008) $
Author:
The Apache MINA Project (dev@mina.apache.org)

Constructor Summary
Log4jXmlFormatter()
           
 
Method Summary
 String format(LogRecord record)
           
 boolean getLocationInfo()
          Returns the current value of the LocationInfo option.
 boolean getProperties()
          Gets whether MDC key-value pairs should be output.
 void setLocationInfo(boolean flag)
          The LocationInfo option takes a boolean value.
 void setProperties(boolean flag)
          Sets whether MDC key-value pairs should be output, default false.
 
Methods inherited from class java.util.logging.Formatter
formatMessage, getHead, getTail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Log4jXmlFormatter

public Log4jXmlFormatter()
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.

Parameters:
flag - whether locationInfo should be output by this layout

getLocationInfo

public boolean getLocationInfo()
Returns the current value of the LocationInfo option.

Returns:
whether locationInfo will be output by this layout

setProperties

public void setProperties(boolean flag)
Sets whether MDC key-value pairs should be output, default false.

Parameters:
flag - new value.

getProperties

public boolean getProperties()
Gets whether MDC key-value pairs should be output.

Returns:
true if MDC key-value pairs are output.

format

public String format(LogRecord record)
Specified by:
format in class Formatter


Copyright © 2004-2008 Apache MINA Project. All Rights Reserved.