public final class XSLTLayout extends Layout implements UnrecognizedElementHandler
<!DOCTYPE log4j:eventSet [<!ENTITY data SYSTEM "data.xml">]> <log4j:eventSet xmlns:log4j="http://jakarta.apache.org/log4j/"> &data </log4j:eventSet>The layout will detect the encoding and media-type specified in the transform. If no encoding is specified in the transform, an xsl:output element specifying the US-ASCII encoding will be inserted before processing the transform. If an encoding is specified in the transform, the same encoding should be explicitly specified for the appender. Extracting MDC values can be expensive when used with log4j releases prior to 1.2.15. Output of MDC values is enabled by default but be suppressed by setting properties to false. Extracting location info can be expensive regardless of log4j version. Output of location info is disabled by default but can be enabled by setting locationInfo to true. Embedded transforms in XML configuration should not depend on namespace prefixes defined earlier in the document as namespace aware parsing in not generally performed when using DOMConfigurator. The transform will serialize and reparse to get the namespace aware document needed.
LINE_SEP, LINE_SEP_LEN
Constructor and Description |
---|
XSLTLayout()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
activateOptions() |
java.lang.String |
format(LoggingEvent event) |
java.lang.String |
getContentType() |
boolean |
getLocationInfo()
Gets whether location info should be output.
|
boolean |
getProperties()
Gets whether MDC key-value pairs should be output.
|
boolean |
ignoresThrowable()
Gets whether throwables should not be output.
|
boolean |
parseUnrecognizedElement(org.w3c.dom.Element element,
java.util.Properties props) |
void |
setIgnoresThrowable(boolean ignoresThrowable)
Sets whether throwables should not 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.
|
void |
setTransform(org.w3c.dom.Document xsltdoc)
Sets XSLT transform.
|
public java.lang.String getContentType()
getContentType
in class Layout
public void setLocationInfo(boolean flag)
If you are embedding this layout within an SMTPAppender
then make sure to set the
LocationInfo option of that appender as well.
flag
- new value.public boolean getLocationInfo()
public void setProperties(boolean flag)
flag
- new value.public boolean getProperties()
public void activateOptions()
activateOptions
in interface OptionHandler
public boolean ignoresThrowable()
ignoresThrowable
in class Layout
public void setIgnoresThrowable(boolean ignoresThrowable)
ignoresThrowable
- if true, throwables should not be output.public java.lang.String format(LoggingEvent event)
public void setTransform(org.w3c.dom.Document xsltdoc) throws javax.xml.transform.TransformerConfigurationException
xsltdoc
- DOM document containing XSLT transform source,
may be modified.javax.xml.transform.TransformerConfigurationException
- if transformer can not be
created.public boolean parseUnrecognizedElement(org.w3c.dom.Element element, java.util.Properties props) throws java.lang.Exception
parseUnrecognizedElement
in interface UnrecognizedElementHandler
java.lang.Exception
Copyright © 2006-2019 OPS4J - Open Participation Software for Java. All Rights Reserved.