org.aselect.system.logging
Class SystemLogger

java.lang.Object
  extended by org.aselect.system.logging.SystemLogger
Direct Known Subclasses:
ASelectAgentSystemLogger, ASelectSystemLogger, AuthSPSystemLogger

public class SystemLogger
extends java.lang.Object

The logger to write system log entries.

Description:
The system logger writes system log entries to a file.

Concurrency issues:
-

Author:
Alfa & Ariss

Constructor Summary
SystemLogger()
          Default constructor.
 
Method Summary
 void closeHandlers()
          Cleanup logger resources.
static java.lang.String formatDetailedError(java.lang.String sModule, java.lang.String sMethod, java.lang.Exception e, java.lang.String sErrorType)
          Deprecated. use log(Level, String, String, String, Throwable) instead.
static java.lang.String formatInternalError(java.lang.String sModule, java.lang.String sMethod, java.lang.Exception e)
          Deprecated. use log(Level, String, String, String, Throwable) instead.
 void init(java.lang.String sLogFileNamePrefix, java.lang.String sLoggerNamespace, ConfigManager oConfigManager, java.lang.Object oLogTargetConfig, java.lang.String sWorkingDir)
          Initializes the System logger.
 void init(java.lang.String sLogDir, java.lang.String sLogFileNamePrefix, java.lang.String sLoggerNamespace, int iFileLimit, int iNumberOfFiles)
          Deprecated. use other init! Initialize the SystemLogger.

Description:
Performs the following steps:
  • Create new FileHandler
  • Open log file
  • Add file handler to this logger
  • Set default level (ALL)

Concurrency issues:
-

Preconditions:
  • sLogDir != null
  • sLogFileNamePrefix != null

Postconditions:
The logger is initialised.
 boolean isDebug()
           
 void log(java.util.logging.Level level, java.lang.String sMessage)
          Write a log item.
 void log(java.util.logging.Level level, java.lang.String sModule, java.lang.String sMethod, java.lang.String sMessage)
          Write a log item with additional information.
 void log(java.util.logging.Level level, java.lang.String sModule, java.lang.String sMethod, java.lang.String sMessage, java.lang.Throwable cause)
          Write a log item with additional information and a cause.
 void log(java.util.logging.Level level, java.lang.String sMessage, java.lang.Throwable cause)
          Write a log item with a cause.
 void setDebug(boolean bDebug)
          Deprecated. use setLevel(Level) instead.
 void setLevel(java.util.logging.Level oLevel)
          Set the level of the system logger.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SystemLogger

public SystemLogger()
Default constructor.

Method Detail

init

public void init(java.lang.String sLogDir,
                 java.lang.String sLogFileNamePrefix,
                 java.lang.String sLoggerNamespace,
                 int iFileLimit,
                 int iNumberOfFiles)
          throws java.lang.Exception
Deprecated. use other init! Initialize the SystemLogger.

Description:
Performs the following steps:
  • Create new FileHandler
  • Open log file
  • Add file handler to this logger
  • Set default level (ALL)

Concurrency issues:
-

Preconditions:
  • sLogDir != null
  • sLogFileNamePrefix != null

Postconditions:
The logger is initialised.

Parameters:
sLogDir - The logging directory.
sLogFileNamePrefix - The log file name prefix (".log" is appended).
sLoggerNamespace - The namespace of this system logger.
iFileLimit - The maximum number of bytes to write to any one file.
iNumberOfFiles - The number of files to use for rotation.
Throws:
java.lang.Exception - If initialisation fails.

init

public void init(java.lang.String sLogFileNamePrefix,
                 java.lang.String sLoggerNamespace,
                 ConfigManager oConfigManager,
                 java.lang.Object oLogTargetConfig,
                 java.lang.String sWorkingDir)
          throws ASelectException
Initializes the System logger.

Description:
  • Reads configuration
  • Creates a FileHandler object and sets it's log level.
  • Creates a Logger object and sets it's log level.


  • Concurrency issues:
    -

    Preconditions:
  • oConfigManager must be initialized
  • oConfigManager may not be null
  • oLogTargetConfig may not be null
  • oSystemLogger may not be null


  • Postconditions:
    Sets _systemLogger class vairable and initializes it.

    Parameters:
    sLogFileNamePrefix - The log file name prefix (".log" is appended).
    sLoggerNamespace - The namespace of this system logger.
    oConfigManager - The config manager used to retrieve the configuration from
    oLogTargetConfig - The 'target' config section containing the file configuration
    sWorkingDir - The workingdir that must be used when no directory is configured
    Throws:
    ASelectException - if initializing failed (missing config items)

    log

    public void log(java.util.logging.Level level,
                    java.lang.String sMessage)
    Write a log item.

    Description:
    Log the given message with the given level to the system log.

    Concurrency issues:
    -

    Preconditions:
    -

    Postconditions:
    -

    Parameters:
    level - The level of the log item.
    sMessage - The message to be logged.

    log

    public void log(java.util.logging.Level level,
                    java.lang.String sMessage,
                    java.lang.Throwable cause)
    Write a log item with a cause.

    Description:
    Log the given message with extended information from the cause and the given level to the system log.

    Concurrency issues:
    -

    Preconditions:
    -

    Postconditions:
    -

    Parameters:
    level - The level of the log item.
    sMessage - The message to be logged.
    cause - The Throwable that causes this log item.

    log

    public void log(java.util.logging.Level level,
                    java.lang.String sModule,
                    java.lang.String sMethod,
                    java.lang.String sMessage)
    Write a log item with additional information.

    Description:
    Formats a log message and log this message.

    Concurrency issues:
    -

    Preconditions:
    Postconditions:
    -

    Parameters:
    level - The log level.
    sModule - The module name.
    sMethod - The method name.
    sMessage - The log message.

    log

    public void log(java.util.logging.Level level,
                    java.lang.String sModule,
                    java.lang.String sMethod,
                    java.lang.String sMessage,
                    java.lang.Throwable cause)
    Write a log item with additional information and a cause.

    Description:
    Formats a log message and log this message including the cause.

    Concurrency issues:
    -

    Preconditions:
    Postconditions:
    -

    Parameters:
    level - The log level.
    sModule - The module name.
    sMethod - The method name.
    sMessage - The log message.
    cause - the logging cause.

    setDebug

    public void setDebug(boolean bDebug)
    Deprecated. use setLevel(Level) instead.

    Enable/disable debug logging.

    Description:
    When set to debugging, messages will be copied to the DebugLogger.

    Concurrency issues:
    -

    Preconditions:
    -

    Postconditions:
    -

    Parameters:
    bDebug - True if debugging should be enabled, otherwise false.

    setLevel

    public void setLevel(java.util.logging.Level oLevel)
    Set the level of the system logger.

    Description:
    Set the log level of this system logger. The follwoing levels are valid:

    Level Description
    SEVERE highest value; severe problems
    WARNING warning messages
    INFO Information messages
    CONFIG Configuration messages
    FINE Extra information like received or sent data.
    FINER If this level is specified the logger will also log stacktraces if available.

    Concurrency issues:
    -

    Preconditions:
    oLevel != null

    Postconditions:

    Parameters:
    oLevel - The new Level to use.

    closeHandlers

    public void closeHandlers()
    Cleanup logger resources.

    Description:
    Closes all openend log handlers.

    Concurrency issues:
    -

    Preconditions:
    -

    Postconditions:
    All used log handlers are closed.


    isDebug

    public boolean isDebug()
    Returns:
    Returns true if debug level is enabled otherwise false.

    formatDetailedError

    public static java.lang.String formatDetailedError(java.lang.String sModule,
                                                       java.lang.String sMethod,
                                                       java.lang.Exception e,
                                                       java.lang.String sErrorType)
    Deprecated. use log(Level, String, String, String, Throwable) instead.

    Format a detailed error message.

    Description:
    Create a detailed message which can be logged.

    Concurrency issues:
    -

    Preconditions:
    -

    Postconditions:
    -

    Parameters:
    sModule - The module (class name) that is to be logged.
    sMethod - The method that is to be logged.
    e - A Exception that is to be logged.
    sErrorType - The type of error.
    Returns:
    A formatted detailed log message.

    formatInternalError

    public static java.lang.String formatInternalError(java.lang.String sModule,
                                                       java.lang.String sMethod,
                                                       java.lang.Exception e)
    Deprecated. use log(Level, String, String, String, Throwable) instead.

    Format a internal error message.

    Description:
    Create a internal error message which can be logged.

    Concurrency issues:
    -

    Preconditions:
    -

    Postconditions:
    -

    Parameters:
    sModule - The module (class name) that is to be logged.
    sMethod - The method that is to be logged.
    e - A Exception that is to be logged.
    Returns:
    A formatted internal error log message.


    Copyright © 2008 SURFnet BV. All Rights Reserved.