Main: Whitepaper FAQ Examples JavaDoc Classloader Performance
Protomatter Software v1.1.8

com.protomatter.syslog.xml
Class SyslogXML

java.lang.Object
  |
  +--com.protomatter.syslog.xml.SyslogXML

public class SyslogXML
extends java.lang.Object

A utility class for configuring Syslog from an XML file.


Field Summary
static java.lang.String XML_PARSER_PROPERTY
          The system property used to set the XML parser class.
 
Method Summary
static boolean configure(org.jdom.Element syslogConfig)
          Configure syslog from the given XML document.
static void configure(java.io.File xmlFile)
          Configure syslog from the given XML file.
static void configure(java.io.File xmlFile, java.lang.String saxDriverClass, boolean showClassloaderWarning)
          Configure syslog from the given XML file using the given JDom SAX driver class as a parser.
static void configure(java.io.InputStream input)
          Configure syslog from the given XML file.
static void configure(java.io.InputStream input, java.lang.String saxDriverClass, boolean showClassloaderWarning)
          Configure syslog from the given XML file using the given JDom SAX driver class as a parser.
static org.jdom.Document getConfiguration()
          Get an XML representation of the current configuration state of Syslog including all loggers, etc.
static void main(java.lang.String[] args)
          Write an example XML configuration file to standard out.
static void writeConfiguration(java.io.OutputStream out)
          Get an XML representation of the current configuration state of Syslog including all loggers, etc and write it to the given output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XML_PARSER_PROPERTY

public static java.lang.String XML_PARSER_PROPERTY
The system property used to set the XML parser class.
Method Detail

writeConfiguration

public static void writeConfiguration(java.io.OutputStream out)
                               throws java.io.IOException
Get an XML representation of the current configuration state of Syslog including all loggers, etc and write it to the given output stream.

getConfiguration

public static org.jdom.Document getConfiguration()
Get an XML representation of the current configuration state of Syslog including all loggers, etc.

configure

public static void configure(java.io.File xmlFile)
                      throws SyslogInitException
Configure syslog from the given XML file. The root element of the file must either be a <Syslog> tag, or it must contain a child that is a <Syslog> tag.

By default, this method will use the default SAX parser to parse the configuration file using JDom. If you wish to change the parser, you can specify the "Syslog.xml.parser" system property. That property should be set to the fully qualified class name of a SAX parser, such as "org.apache.xerces.parsers.SAXParser".

See Also:
configure(Element element)

configure

public static void configure(java.io.InputStream input)
                      throws SyslogInitException
Configure syslog from the given XML file. The root element of the file must either be a <Syslog> tag, or it must contain a child that is a <Syslog> tag.

By default, this method will use the default SAX parser to parse the configuration file using JDom. If you wish to change the parser, you can specify the "Syslog.xml.parser" system property. That property should be set to the fully qualified class name of a SAX parser, such as "org.apache.xerces.parsers.SAXParser".

See Also:
configure(Element element)

configure

public static void configure(java.io.File xmlFile,
                             java.lang.String saxDriverClass,
                             boolean showClassloaderWarning)
                      throws SyslogInitException
Configure syslog from the given XML file using the given JDom SAX driver class as a parser. The driver class is given as a parameter to the constructor for a org.jdom.input.SAXBuilder object. For instance, to use the Apache Xerces parser, pass in "org.apache.xerces.parsers.SAXParser" as the driver.
Parameters:
xmlFile - Configuration file
saxDriverClass - XML parser class name
showClassloaderWarning - Should the classloader warning be shown?
See Also:
configure(Element element)

configure

public static void configure(java.io.InputStream input,
                             java.lang.String saxDriverClass,
                             boolean showClassloaderWarning)
                      throws SyslogInitException
Configure syslog from the given XML file using the given JDom SAX driver class as a parser. The driver class is given as a parameter to the constructor for a org.jdom.input.SAXBuilder object. For instance, to use the Apache Xerces parser, pass in "org.apache.xerces.parsers.SAXParser" as the driver.
Parameters:
input - InputStream carrying the XML configuration data
saxDriverClass - XML parser class name
showClassloaderWarning - Should the classloader warning be shown?
See Also:
configure(Element element)

configure

public static boolean configure(org.jdom.Element syslogConfig)
                         throws SyslogInitException
Configure syslog from the given XML document. The document should look like this:



  <Syslog
    defaultMask="DefaultSyslogLogMask"
    hostname="LocalHostName"
    computeCaller="true|false"
    alwaysComputeCaller="true|false"
    flushThreadInterval="milliseconds"
  >

    <Debug enabled="true|false" scan="true|false">
      <name level="trace|debug|info">name1</name>
      <name level="trace|debug|info">pattern1</name>
      <name level="trace|debug|info">name2</name>
      <name level="trace|debug|info">pattern2</name>
    </Debug>

    <Logger
      name="LoggerName"
      class="LoggerClassName"
    >
      <!-- Logger directives -->
    </Logger>

    <!-- More loggers here -->

  </Syslog>
  

Each logger is loaded and configured with it's Logger XML element. See the Javadoc for individual loggers for more information.

The default, system-wide log mask is set to be "at or above" the value of the defaultMask attribute (if present). The hostname that Syslog thinks is "local" is set to the value of the hostname attribute (if present).

If the flushThreadInterval attribute is set, it is interpreted as the number of milliseconds for a background thread to sleep between attempts to flush all the loggers.

The computeCaller and alwaysComputeCaller attributes correspond to the Syslog.setComputeCaller() and Syslog.setAlwaysComputeCaller() methods.

The optional <Debug> element contains a list of <name> elements, which are passed to the addXXXName() method of the com.protomatter.util.Debug class.

See Also:
BasicLogger

main

public static final void main(java.lang.String[] args)
Write an example XML configuration file to standard out. The optional first command line argument is a filename to load as a configuration and then print to standard out. This can be useful, as all the default values are populated (which may not have been present in the input file).
See Also:
configure(Element element)

Protomatter Software v1.1.8
Copyright 1998-2002 Nate Sammons

Protomatter Software v1.1.8 http://protomatter.sourceforge.net/1.1.8