EAF 7.6 Implementation

com.lutris.logging
Class Log4jLogger

java.lang.Object
  extended by com.lutris.logging.Logger
      extended by com.lutris.logging.Log4jLogger

public class Log4jLogger
extends com.lutris.logging.Logger

Log4j implementation of the Logger. This is general-purpose logging facility. A client that needs additional functionality can either extend this class or provide there own implementationm of Logger.

Currently this is a bare-bones class that writes INFO and above levels to stderr and all others to a log file.

Author:
Vladimir Puskas, Predrag Djoic, Sinisa Milosevic
See Also:
Logger, LogChannel

Field Summary
protected  java.lang.String DEFAULT_LOG_CONFIG_FILE
          Default Log4j configuration file
protected  boolean[] enabledLevelFlags
          Table of levels that are to be enabled.
protected  java.lang.String[] levelNames
          Table translating level number to name and the largest entry in the array that is valid.
protected  boolean[] logFileLevelFlags
          Table of levels that are to be written to the log file.
protected  int numLevels
           
protected  boolean[] stderrLevelFlags
          Table of levels that are to be written to stderr Accessed directly by the channel.
 
Fields inherited from class com.lutris.logging.Logger
ALERT, centralLogger, CRITICAL, DEBUG, DEBUG1, DEBUG2, DEBUG3, DEBUG4, DEBUG5, DEBUG6, DEBUG7, DEBUG8, DEBUG9, DEBUGTMP, EMERGENCY, ERROR, INFO, MAX_STD_LEVEL, NOTICE, standardLevelNames, WARNING
 
Constructor Summary
Log4jLogger(boolean makeCentral)
          Construct a new logger.
 
Method Summary
 void configure(com.lutris.util.Config logConfig)
          Configure Logger with given config section
 void configure(java.lang.String log4jConfFile)
          Configure the logger.
 com.lutris.logging.LogChannel getChannel(java.lang.String facility)
          Get the log channel object for a facility.
 int getLevel(java.lang.String level)
          Convert a symbolic level to an integer identifier, creating it if it doesn't exist
 java.lang.String getLevelName(int level)
          Convert an int to a symbolic level name.
 
Methods inherited from class com.lutris.logging.Logger
getCentralLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

levelNames

protected java.lang.String[] levelNames
Table translating level number to name and the largest entry in the array that is valid. Will be expanded if needed.


numLevels

protected int numLevels

enabledLevelFlags

protected boolean[] enabledLevelFlags
Table of levels that are to be enabled. Accessed directly by the channel. If null, ignored.


logFileLevelFlags

protected boolean[] logFileLevelFlags
Table of levels that are to be written to the log file. Accessed directly by the channel. If null, ignored.


stderrLevelFlags

protected boolean[] stderrLevelFlags
Table of levels that are to be written to stderr Accessed directly by the channel. If null, then the default behavior of writing serious standard levels to stderr is in affect.


DEFAULT_LOG_CONFIG_FILE

protected java.lang.String DEFAULT_LOG_CONFIG_FILE
Default Log4j configuration file

Constructor Detail

Log4jLogger

public Log4jLogger(boolean makeCentral)
Construct a new logger. Configuration is not done now, to allow the logger to be created very early.

Parameters:
makeCentral - Make this object the central logging object.
Method Detail

configure

public void configure(java.lang.String log4jConfFile)
               throws com.lutris.util.ConfigException
Configure the logger. All current configuration is discarded. This is a simplistic initial implementation that just allows directing to a single log file or stderr on a level basis. A more complete interface will be provided in the future.

Specified by:
configure in class com.lutris.logging.Logger
Parameters:
logFile - The log file to write to.
fileLevels - List of levels that will be written to the file.
stderrLevels - List of levels that will be written to stderr. The same level may appear in both lists.
Throws:
java.io.IOException - If an error occurs opening the log file.
com.lutris.util.ConfigException

getChannel

public com.lutris.logging.LogChannel getChannel(java.lang.String facility)
Get the log channel object for a facility. For a given facility, the same object is always returned.

Specified by:
getChannel in class com.lutris.logging.Logger
Parameters:
facility - Facility the channel is associated with.

getLevel

public int getLevel(java.lang.String level)
Convert a symbolic level to an integer identifier, creating it if it doesn't exist

Parameters:
level - Symbolic level that is to be checked.
Returns:
The numeric level identifier

getLevelName

public java.lang.String getLevelName(int level)
Convert an int to a symbolic level name.

Parameters:
level - an int level.
Returns:
The String symolic level name or null if there is not one.

configure

public void configure(com.lutris.util.Config logConfig)
               throws com.lutris.util.ConfigException
Configure Logger with given config section

Specified by:
configure in class com.lutris.logging.Logger
Parameters:
logConfig - containing parameters for configuring logger
Throws:
com.lutris.util.ConfigException

EAF 7.6 Implementation