com.sun.slamd.server
Class Logger

java.lang.Object
  extended bycom.sun.slamd.server.Logger
All Implemented Interfaces:
ConfigSubscriber

public class Logger
extends java.lang.Object
implements ConfigSubscriber

This class handles all logging performed by the SLAMD server. It is a multithreaded component to allow changes to be logged with minimal impact on the performance of other components in the SLAMD server that use the logger (like the scheduler). However, configuration parameters make it possible to customize this behavior so that logging can be done synchronously if this is desired for some reason (e.g., debugging purposes). Note that minimal logging will be performed in this class to prevent logging loops, but any significant problems will be logged to standard error.


Field Summary
static java.lang.String CONFIG_SUBSCRIBER_NAME
          The name used to register the logger as a subscriber to the configuration handler.
 
Constructor Summary
Logger(SLAMDServer slamdServer)
          Creates a new instance of a logger to work with the provided SLAMD server.
 
Method Summary
 void closeLogger()
          Sets a flag that indicates that the logger should stop operating.
 java.lang.String getSubscriberName()
          Retrieves the name that the logger uses to subscribe to the configuration handler in order to be notified of configuration changes.
 ParameterList getSubscriberParameters()
          Retrieves the set of configuration parameters associated with this configuration subscriber.
 void logMessage(java.lang.String message)
          Performs the work of actually logging the specified message.
 void refreshSubscriberConfiguration()
          Re-reads all configuration information used by the logger.
 void refreshSubscriberConfiguration(java.lang.String parameterName)
          Re-reads the configuration for the specified parameter, if it is applicable to the logger.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIG_SUBSCRIBER_NAME

public static final java.lang.String CONFIG_SUBSCRIBER_NAME
The name used to register the logger as a subscriber to the configuration handler.

See Also:
Constant Field Values
Constructor Detail

Logger

public Logger(SLAMDServer slamdServer)
       throws SLAMDServerException
Creates a new instance of a logger to work with the provided SLAMD server.

Parameters:
slamdServer - The SLAMD server instance with which this logger is to be associated.
Throws:
SLAMDServerException - If a problem is encountered while creating the logger.
Method Detail

logMessage

public void logMessage(java.lang.String message)
Performs the work of actually logging the specified message. If the logger is configured to operate synchronously, then it is written immediately. If the logger is configured to operate asynchronously, then the message is written to the log buffer to be picked up by the logger thread.

Parameters:
message - The message to be written to the log.

closeLogger

public void closeLogger()
Sets a flag that indicates that the logger should stop operating. If the logger is working synchronously, then it actually closes the log file. otherwise, it waits for the logging thread to complete. This function will not return until the logging subsystem has completely shut down.


getSubscriberName

public java.lang.String getSubscriberName()
Retrieves the name that the logger uses to subscribe to the configuration handler in order to be notified of configuration changes.

Specified by:
getSubscriberName in interface ConfigSubscriber
Returns:
The name that the logger uses to subscribe to the configuration handler in order to be notified of configuration changes.

getSubscriberParameters

public ParameterList getSubscriberParameters()
Retrieves the set of configuration parameters associated with this configuration subscriber.

Specified by:
getSubscriberParameters in interface ConfigSubscriber
Returns:
The set of configuration parameters associated with this configuration subscriber.

refreshSubscriberConfiguration

public void refreshSubscriberConfiguration()
                                    throws SLAMDServerException
Re-reads all configuration information used by the logger. In this case, this is the name of the file to which to log and the flag indicating whether synchronous logging should always flush after writing. It is not possible to dynamically switch between synchronous and asynchronous logging.

If the name of the log file changes, then the logger writer will be closed and a new one opened with the specified name. There is no guarantee that any messages currently in the log buffer will be written to the original log file before it is closed (they may be written to the new log file instead).

Specified by:
refreshSubscriberConfiguration in interface ConfigSubscriber
Throws:
SLAMDServerException - If a new log filename is detected and there is a problem while closing the existing log file and/or opening the new one.

refreshSubscriberConfiguration

public void refreshSubscriberConfiguration(java.lang.String parameterName)
                                    throws SLAMDServerException
Re-reads the configuration for the specified parameter, if it is applicable to the logger. Only the name of the log file and the flag indicating whether synchronous logging should always flush after writing may be dynamically reconfigured. It is not possible to dynamically switch between synchronous and asynchronous logging.

If the name of the log file changes, then the logger writer will be closed and a new one opened with the specified name. There is no guarantee that any messages currently in the log buffer will be written to the original log file before it is closed (they may be written to the new log file instead).

Specified by:
refreshSubscriberConfiguration in interface ConfigSubscriber
Parameters:
parameterName - The name of the parameter to be re-read from the configuration.
Throws:
SLAMDServerException - If a new log filename is detected and there is a problem while closing the existing log file and/or opening the new one.