- java.lang.Object
-
- java.util.logging.Formatter
-
- org.jboss.logmanager.ExtFormatter
-
- org.jboss.logmanager.formatters.StructuredFormatter
-
- org.jboss.logmanager.formatters.XmlFormatter
-
public class XmlFormatter extends StructuredFormatter
A formatter that outputs the record in XML format.The details include;
- Author:
- James R. Perkins
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.jboss.logmanager.formatters.StructuredFormatter
StructuredFormatter.ExceptionOutputType, StructuredFormatter.Generator, StructuredFormatter.Key
-
Nested classes/interfaces inherited from class org.jboss.logmanager.ExtFormatter
ExtFormatter.Delegating
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_NAMESPACE
-
Constructor Summary
Constructors Constructor Description XmlFormatter()Creates a new XML formatter.XmlFormatter(String keyOverrides)Creates a new XML formatter.XmlFormatter(Map<StructuredFormatter.Key,String> keyOverrides)Creates a new XML formatter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StructuredFormatter.GeneratorcreateGenerator(Writer writer)Creates the generator used to create the structured data.StringgetNamespaceUri()Returns the namespace URI used for each record ifisPrintNamespace()istrue.booleanisPrettyPrint()Indicates whether or not pretty printing is enabled.booleanisPrintNamespace()Indicates whether or not the name space should be written on the<record/>.voidsetNamespaceUri(String namespaceUri)Sets the namespace URI used for each record ifisPrintNamespace()istrue.voidsetPrettyPrint(boolean prettyPrint)Turns on or off pretty printing.voidsetPrintNamespace(boolean printNamespace)Turns on or off the printing of the namespace for each<record/>.-
Methods inherited from class org.jboss.logmanager.formatters.StructuredFormatter
after, before, format, getDateTimeFormatter, getExceptionOutputType, getKey, getKeyOverrides, getMetaData, getRecordDelimiter, getZoneId, isCallerCalculationRequired, isDetailedExceptionOutputType, isFormattedExceptionOutputType, isPrintDetails, setDateFormat, setExceptionOutputType, setMetaData, setPrintDetails, setRecordDelimiter, setZoneId
-
Methods inherited from class org.jboss.logmanager.ExtFormatter
format, formatMessage, formatMessageLegacy, formatMessageNone, formatMessagePrintf, wrap
-
-
-
-
Field Detail
-
DEFAULT_NAMESPACE
public static final String DEFAULT_NAMESPACE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
XmlFormatter
public XmlFormatter()
Creates a new XML formatter.
-
XmlFormatter
public XmlFormatter(String keyOverrides)
Creates a new XML formatter.If the
keyOverridesis empty the default namespace will be used.- Parameters:
keyOverrides- a string representation of a map to override keys- See Also:
PropertyValues.stringToEnumMap(Class, String)
-
XmlFormatter
public XmlFormatter(Map<StructuredFormatter.Key,String> keyOverrides)
Creates a new XML formatter.If the
keyOverridesis empty the default namespace will be used.- Parameters:
keyOverrides- a map of overrides for the default keys
-
-
Method Detail
-
isPrettyPrint
public boolean isPrettyPrint()
Indicates whether or not pretty printing is enabled.- Returns:
trueif pretty printing is enabled, otherwisefalse
-
setPrettyPrint
public void setPrettyPrint(boolean prettyPrint)
Turns on or off pretty printing.- Parameters:
prettyPrint-trueto turn on pretty printing orfalseto turn it off
-
isPrintNamespace
public boolean isPrintNamespace()
Indicates whether or not the name space should be written on the<record/>.- Returns:
trueif the name space should be written for each record
-
setPrintNamespace
public void setPrintNamespace(boolean printNamespace)
Turns on or off the printing of the namespace for each<record/>. This is set tofalseby default.- Parameters:
printNamespace-trueif the name space should be written for each record
-
getNamespaceUri
public String getNamespaceUri()
Returns the namespace URI used for each record ifisPrintNamespace()istrue.- Returns:
- the namespace URI, may be
nullif explicitly set tonull
-
setNamespaceUri
public void setNamespaceUri(String namespaceUri)
Sets the namespace URI used for each record ifisPrintNamespace()istrue.- Parameters:
namespaceUri- the namespace to use ornullif no namespace URI should be used regardless of theisPrintNamespace()value
-
createGenerator
protected StructuredFormatter.Generator createGenerator(Writer writer) throws Exception
Description copied from class:StructuredFormatterCreates the generator used to create the structured data.- Specified by:
createGeneratorin classStructuredFormatter- Returns:
- the generator to use
- Throws:
Exception- if an error occurs creating the generator
-
-