SK.gnome.dwarf.sample
Class XMLLogger

java.lang.Object
  extended bySK.gnome.dwarf.GenericService
      extended bySK.gnome.dwarf.thread.ThreadService
          extended bySK.gnome.dwarf.log.GenericLogger
              extended bySK.gnome.dwarf.log.StreamLogger
                  extended bySK.gnome.dwarf.log.FileLogger
                      extended bySK.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.


Field Summary
 
Fields inherited from class SK.gnome.dwarf.log.FileLogger
autoFlush, encoding, file
 
Fields inherited from class SK.gnome.dwarf.log.StreamLogger
dateTime, dateTimeFormat, extendedInfo, out
 
Fields inherited from class SK.gnome.dwarf.log.GenericLogger
facilities, levels, lock, LOG_FACILITY_ALL
 
Fields inherited from class SK.gnome.dwarf.thread.ThreadService
daemon, thread
 
Fields inherited from class SK.gnome.dwarf.GenericService
initParameters, parent
 
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.log.FileLogger
report, setAutoFlush, setEncoding, setFile, shutdown
 
Methods inherited from class SK.gnome.dwarf.log.StreamLogger
setDateTime, setDateTimeFormat, setDateTimeFormat, setExtendedInfo, wouldLog
 
Methods inherited from class SK.gnome.dwarf.log.GenericLogger
enableThread, getLastAccessed, log, log, loop, setFacilities, setLevels, setMarkInterval, setRepeatedInterval, start
 
Methods inherited from class SK.gnome.dwarf.thread.ThreadService
finish, run, setDaemon, stop
 
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
 

Constructor Detail

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.

Method Detail

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.