SK.gnome.dwarf.log
Class FileLogger

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
All Implemented Interfaces:
Logger, Reportable, java.lang.Runnable, Service
Direct Known Subclasses:
XMLLogger

public class FileLogger
extends StreamLogger
implements Reportable

The file logger.

This logger writes the log messages to a file.


Field Summary
protected  boolean autoFlush
          Whether to flush automatically the output stream.
protected  java.lang.String encoding
          The output stream character encoding.
protected  java.io.File file
          Physical file which the log messages will be written to.
 
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
FileLogger(java.lang.String name)
          Creates a new FileLogger.
 
Method Summary
 void init(Server parent)
          Inititalizes the service and sets the output stream.
 java.lang.String report()
          Returns the service report.
 void setAutoFlush(boolean enable)
          Enables or disables the automatic flushing of the output stream.
 void setEncoding(java.lang.String encoding)
          Sets the output stream character encoding.
 void setFile(java.io.File file)
          Sets the file to write the log messages to.
 void shutdown()
          Shuts down the service and closes the output stream.
 
Methods inherited from class SK.gnome.dwarf.log.StreamLogger
setDateTime, setDateTimeFormat, setDateTimeFormat, setExtendedInfo, wouldLog, write
 
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
 

Field Detail

file

protected java.io.File file
Physical file which the log messages will be written to.


autoFlush

protected boolean autoFlush
Whether to flush automatically the output stream.

Default value: false


encoding

protected java.lang.String encoding
The output stream character encoding.

Default value: (system-dependent)

Constructor Detail

FileLogger

public FileLogger(java.lang.String name)
Creates a new FileLogger.

Method Detail

setFile

public void setFile(java.io.File file)
Sets the file to write the log messages to.

Parameters:
file - the file
See Also:
file

setAutoFlush

public void setAutoFlush(boolean enable)
Enables or disables the automatic flushing of the output stream.

Parameters:
enable - true to enable automatic flushing
See Also:
autoFlush

setEncoding

public void setEncoding(java.lang.String encoding)
Sets the output stream character encoding.

Parameters:
encoding - the Java encoding name
See Also:
encoding

init

public void init(Server parent)
          throws ServiceException
Inititalizes the service and sets the output stream.

The output stream is set to the file specified by the value of the file field. The file is opened for appending, created first if necessary. The output stream is buffered by default. Use the setAutoFlush method to turn on or off the automatic flushing of the output stream.

Specified by:
init in interface Service
Overrides:
init in class GenericService
Throws:
ServiceException

shutdown

public void shutdown()
Shuts down the service and closes the output stream.

Specified by:
shutdown in interface Service
Overrides:
shutdown in class GenericLogger

report

public java.lang.String report()
Returns the service report.

Returns an information about the physical file used.

Specified by:
report in interface Reportable
Returns:
the service name plus the file name and current file size in kB


Copyright (c) 1999-2005, Gnome Ltd. All rights reserved.