|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.logging.log4j.core.layout.AbstractLayout<String>
org.apache.logging.log4j.core.layout.AbstractStringLayout
org.apache.logging.log4j.core.layout.XMLLayout
public class XMLLayout
The output of the XMLLayout consists of a series of log4j:event elements as defined in the log4j.dtd. If configured to do so it will output a complete well-formed XML file. The output is designed to be included as an external entity in a separate file to form a correct XML file.
For example, if abc
is the name of the file where
the XMLLayout ouput goes, then a well-formed XML file would be:
<?xml version="1.0" ?> <!DOCTYPE log4j:eventSet SYSTEM "log4j.dtd" [<!ENTITY data SYSTEM "abc">]> <log4j:eventSet version="1.2" xmlns:log4j="http://logging.apache.org/log4j/"> &data; </log4j:eventSet>
This approach enforces the independence of the XMLLayout and the appender where it is embedded.
The version
attribute helps components to correctly
interpret output generated by XMLLayout. The value of this
attribute should be "1.1" for output generated by log4j versions
prior to log4j 1.2 (final release) and "1.2" for release 1.2 and
later.
Field Summary |
---|
Fields inherited from class org.apache.logging.log4j.core.layout.AbstractLayout |
---|
footer, header, LOGGER |
Constructor Summary | |
---|---|
protected |
XMLLayout(boolean locationInfo,
boolean properties,
boolean complete,
Charset charset)
|
Method Summary | |
---|---|
static XMLLayout |
createLayout(String locationInfo,
String properties,
String complete,
String charsetName)
Create an XML Layout. |
Map<String,String> |
getContentFormat()
XMLLayout's content format is specified by: Key: "dtd" Value: "log4j.dtd" Key: "version" Value: "1.2" |
String |
getContentType()
Returns the content type output by this layout. |
byte[] |
getFooter()
Returns appropriate XML headers. |
byte[] |
getHeader()
Returns appropriate XML headers. |
String |
toSerializable(LogEvent event)
Formats a LogEvent in conformance with the log4j.dtd. |
Methods inherited from class org.apache.logging.log4j.core.layout.AbstractStringLayout |
---|
getCharset, toByteArray |
Methods inherited from class org.apache.logging.log4j.core.layout.AbstractLayout |
---|
setFooter, setHeader |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected XMLLayout(boolean locationInfo, boolean properties, boolean complete, Charset charset)
Method Detail |
---|
public String toSerializable(LogEvent event)
LogEvent
in conformance with the log4j.dtd.
event
- The LogEvent.
public byte[] getHeader()
getHeader
in interface Layout<String>
getHeader
in class AbstractLayout<String>
public byte[] getFooter()
getFooter
in interface Layout<String>
getFooter
in class AbstractLayout<String>
public Map<String,String> getContentFormat()
public String getContentType()
Layout
getContentType
in interface Layout<String>
getContentType
in class AbstractStringLayout
public static XMLLayout createLayout(String locationInfo, String properties, String complete, String charsetName)
locationInfo
- If "true" include the location information in the generated XML.properties
- If "true" include the thread context in the generated XML.complete
- If "true" include the XML header.charsetName
- The character set to use.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 1999-2013 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.