SK.gnome.dwarf.sample
Class XMLLogger
java.lang.Object
SK.gnome.dwarf.GenericService
SK.gnome.dwarf.thread.ThreadService
SK.gnome.dwarf.log.GenericLogger
SK.gnome.dwarf.log.StreamLogger
SK.gnome.dwarf.log.FileLogger
SK.gnome.dwarf.sample.XMLLogger
- All Implemented Interfaces:
- Logger, Reportable, java.lang.Runnable, Service
- public class XMLLogger
- extends FileLogger
The XML file logger.
This logger writes the log messages to a XML file. The DTD for the XML document
is as follows:
<!ELEMENT log (message?,error?)>
<!ATTLIST log time CDATA
level CDATA
facility CDATA>
<!ELEMENT message (#PCDATA)>
<!ELEMENT error (#PCDATA)>
<!ATTLIST error class CDATA #REQUIRED>
The character encoding of the XML document may be specified via the FileLogger.setEncoding(String)
method. By default, is uses the "UTF-8" encoding, which is suitable for most cases.
Fields inherited from interface SK.gnome.dwarf.Service |
INITIALIZED, LOG_DEBUG, LOG_ERROR, LOG_FATAL, LOG_INFO, LOG_TRACE, LOG_WARN, LOG_XFER, SHUTDOWN, STARTED, STOPPED |
Constructor Summary |
XMLLogger(java.lang.String name)
Creates new FileLogger.
|
Method Summary |
void |
init(Server parent)
Initializes the service.
|
protected void |
write(long time,
java.lang.String facility,
LogLevel level,
java.lang.String message,
java.lang.Throwable error)
Writes the message to the output stream.
|
Methods inherited from class SK.gnome.dwarf.GenericService |
getAuthenticator, getAuthFacility, getFullName, getInitParameter, getInitParameterNames, getLogFacility, getLogger, getName, getParameters, getPrincipal, getShutdownTimeout, getState, log, log, login, logout, setAuthFacility, setInitParameters, setLogFacility, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
XMLLogger
public XMLLogger(java.lang.String name)
- Creates new FileLogger.
The FileLogger.encoding
protected field is initialized to default "UTF-8"
character encoding. It may be changed via the FileLogger.setEncoding(String)
method.
init
public void init(Server parent)
throws ServiceException
- Initializes the service.
It calls the superclass' initialization method and then writes the XML header
to the output file.
- Specified by:
init
in interface Service
- Overrides:
init
in class FileLogger
- Throws:
ServiceException
write
protected void write(long time,
java.lang.String facility,
LogLevel level,
java.lang.String message,
java.lang.Throwable error)
- Description copied from class:
StreamLogger
- Writes the message to the output stream.
The time argument will be formatted according to the StreamLogger.dateTimeFormat
field value if writting of the date and time information is enabled via the
StreamLogger.setDateTime(boolean)
method.
- Overrides:
write
in class StreamLogger
Copyright (c) 1999-2005, Gnome Ltd. All rights reserved.