public class Log4jXmlFormatter
extends java.util.logging.Formatter
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
| Modifier and Type | Field and Description |
|---|---|
private java.lang.StringBuffer |
buf |
private int |
DEFAULT_SIZE |
private boolean |
locationInfo |
private boolean |
properties |
private int |
UPPER_LIMIT |
| Constructor and Description |
|---|
Log4jXmlFormatter() |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
format(java.util.logging.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.
|
private final int DEFAULT_SIZE
private final int UPPER_LIMIT
private java.lang.StringBuffer buf
private boolean locationInfo
private boolean properties
public void setLocationInfo(boolean flag)
flag - whether locationInfo should be output by this layoutpublic boolean getLocationInfo()
public void setProperties(boolean flag)
flag - new value.public boolean getProperties()
public java.lang.String format(java.util.logging.LogRecord record)
format in class java.util.logging.Formatter