Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

alma::acs::logging::AcsLogger Class Reference

Inheritance diagram for alma::acs::logging::AcsLogger:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 AcsLogger (String name, String resourceBundleName, LogConfig logConfig)
String getProcessName ()
String getSourceObject ()
void logToAudience (Level level, String msg, String audience)
void logToAudience (Level level, String msg, Throwable thr, String audience)
AcsLogRecord createAcsLogRecord (Level level, String msg)
void log (LogRecord record)
void configureLogging (LogConfig newLogConfig)
void addLoggerClass (Class<?> loggerClass)
void addIgnoreLogs (String className, String methodName)

Static Public Member Functions

AcsLogger createUnconfiguredLogger (String name, String resourceBundleName)
AcsLogger fromJdkLogger (Logger logger, String wrapLoggerName)

Protected Member Functions

 AcsLogger (String name, String resourceBundleName, LogConfig logConfig, boolean allowNullLogConfig, Logger delegate)

Protected Attributes

final Logger delegate

Static Protected Attributes

final int offValue = Level.OFF.intValue()

Package Functions

void setLoggerName (String newLoggerName)
String getLoggerName ()
void setProcessName (String processName)
void setSourceObject (String sourceObject)
void configureLevels (UnnamedLogger loggerConfig)

Private Member Functions

final String concatenateIgnoreLogData (String className, String methodName)

Private Attributes

final Set< String > loggerClassNames = new HashSet<String>()
final Set< String > callStacksToBeIgnored = new HashSet<String>()
LogConfig logConfig
String loggerName
String processName
String sourceObject
boolean noLevelWarningPrinted = false
final boolean DEBUG = Boolean.getBoolean("alma.acs.logging.verbose")

Detailed Description

A Logger that attaches additional information to the produced LogRecords.

This class should be used only by ACS or by similar framework layers in the Operator GUI etc. Normal application code should get the Logger object from the ContainerServices.

Design note: the additional data (thread name, line of code) are really most interesting for the remotely sent log messages. Thus an alternative implementation could put the code from log(LogRecord) into class alma.acs.logging.AcsLoggingHandler, and not use a custom Logger class at all. The main reason we do it anyway is to avoid throwing the dummy exception (that delivers the stack trace) twice.

Author:
hsommer created May 30, 2005 4:09:47 PM


Constructor & Destructor Documentation

alma::acs::logging::AcsLogger::AcsLogger String  name,
String  resourceBundleName,
LogConfig  logConfig
[inline]
 

Standard constructor that configures this logger from logConfig and also registers for log config changes.

Parameters:
name the logger's name
resourceBundleName may be null
logConfig the ACS logging configuration object, which gives optional access to the CDB.

alma::acs::logging::AcsLogger::AcsLogger String  name,
String  resourceBundleName,
LogConfig  logConfig,
boolean  allowNullLogConfig,
Logger  delegate
[inline, protected]
 

Auxiliary ctor. Don't use it directly from outside of this class.

Parameters:
logConfig may be null if allowNullLogConfig==true


Member Function Documentation

void alma::acs::logging::AcsLogger::addIgnoreLogs String  className,
String  methodName
[inline]
 

The AcsLogger can be configured to ignore certain logs. Note that this feature should not be used as a substitute for properly adjusting log levels and using repeat guards etc throughout the code. A valid use case would be to avoid "positive feedback" when the sending of a log produces one or more log messages, some of which may only be produced under special conditions, e.g. those coming from jacorb.

Parameters:
className class name where the log comes from. Must not be null.
methodName method name where the log comes from. Must not be null.

void alma::acs::logging::AcsLogger::addLoggerClass Class<?>  loggerClass  )  [inline]
 

Adds a logger class, which will be used to skip entries in the stack trace until the original logging method is found. If you have a delegation chain that involves loggers besides AcsLogger and the normal JDK Logger, make sure you call this method for each of them.

Parameters:
loggerClass 

final String alma::acs::logging::AcsLogger::concatenateIgnoreLogData String  className,
String  methodName
[inline, private]
 

Ensures that the same format of concatenated String is used in addIgnoreLogs(String, String) and log(LogRecord). Being private final, the compiler will hopefully inline calls to this method.

Parameters:
fileName 
methodName 
Returns:

void alma::acs::logging::AcsLogger::configureLevels UnnamedLogger  loggerConfig  )  [inline, package]
 

Extracted from configureLogging(LogConfig) to support also configuration of Loggers created with createUnconfiguredLogger(String, String) which do not know about a shared LogConfig.

Parameters:
loggerConfig 

void alma::acs::logging::AcsLogger::configureLogging LogConfig  newLogConfig  )  [inline]
 

Callback method, configures this logger from the data in logConfig.

See also:
alma.acs.logging.config.LogConfigSubscriber::configureLogging(alma.acs.logging.config.LogConfig)

AcsLogRecord alma::acs::logging::AcsLogger::createAcsLogRecord Level  level,
String  msg
[inline]
 

AcsLogger alma::acs::logging::AcsLogger::createUnconfiguredLogger String  name,
String  resourceBundleName
[inline, static]
 

Non-standard factory method to be used only for special offline or testing purposes where typically an AcsLogger must be provided by an alternative implementation of ContainerServices. The returned AcsLogger is just like a JDK Logger obtained from Logger#getLogger(String, String).

Note that we do not supply a LogConfig and therefore the new AcsLogger cannot register itself for initial configuration or later configuration change notifications.
It is the client's responsibility to configure the log level and parent logger of the returned AcsLogger!

Parameters:
name the logger's name
resourceBundleName 
Returns:
AcsLogger that is as close to a normal JDK Logger as possible.
Exceptions:
IllegalArgumentException If a Logger of the given name exists but is not an AcsLogger, or if an AcsLogger of the given name exists but has a different resourceBundleName.

AcsLogger alma::acs::logging::AcsLogger::fromJdkLogger Logger  logger,
String  wrapLoggerName
[inline, static]
 

Client applications that use ACS class ComponentClient may need to turn their own JDK Logger into an AcsLogger.

If logger is itself of sub-type AcsLogger then it is returned directly without being wrapped. The wrapping logger shares the parent logger and the log level with the provided logger.

Parameters:
logger the JDK logger
wrapperName Name of the returned AcsLogger. May be null in which case the delegate's name plus "wrapper" is taken.
Returns:
an AcsLogger that delegates to the given logger.
Since:
ACS 8.0

String alma::acs::logging::AcsLogger::getLoggerName  )  [inline, package]
 

String alma::acs::logging::AcsLogger::getProcessName  )  [inline]
 

String alma::acs::logging::AcsLogger::getSourceObject  )  [inline]
 

void alma::acs::logging::AcsLogger::log LogRecord  record  )  [inline]
 

Logs the given LogRecord. The record can be modified or dropped by the optional filters provided in addLogRecordFilter(alma.acs.logging.AcsLogger.LogRecordFilter).

Adding of context information:

  • If the LogRecord has a parameter that is a map which contains additional information about the line of code, thread, etc., the log record will be taken as provided, and no context information will be added. This can be useful if
    • the log record was reconstructed from a remote error by the ACS error handling code (see AcsJException), or
    • if in very exceptional cases application code needs to manipulate such information by hand.
  • otherwise, context information is inferred, similar to LogRecord#inferCaller(), but additionally including thread name and line of code.
Note that by overloading this method, we intercept all logging activities of the base class.

See also:
java.util.logging.Logger#log(java.util.logging.LogRecord)

void alma::acs::logging::AcsLogger::logToAudience Level  level,
String  msg,
Throwable  thr,
String  audience
[inline]
 

void alma::acs::logging::AcsLogger::logToAudience Level  level,
String  msg,
String  audience
[inline]
 

void alma::acs::logging::AcsLogger::setLoggerName String  newLoggerName  )  [inline, package]
 

Optionally sets a logger name that can be different from the Logger#name passed in the constructor. The new name will be used for the LogRecords produced by this class. This allows changing the name later on, e.g. when a container name or JUnit test name should be appended to the simple name of a Corba logger.

Parameters:
loggerName 

void alma::acs::logging::AcsLogger::setProcessName String  processName  )  [inline, package]
 

void alma::acs::logging::AcsLogger::setSourceObject String  sourceObject  )  [inline, package]
 


Member Data Documentation

final Set<String> alma::acs::logging::AcsLogger::callStacksToBeIgnored = new HashSet<String>() [private]
 

Concatenation of class and method names, with a "#" in between. Used for fast comparison of log stack frames, see addIgnoreLogs(String, String).

final boolean alma::acs::logging::AcsLogger::DEBUG = Boolean.getBoolean("alma.acs.logging.verbose") [private]
 

final Logger alma::acs::logging::AcsLogger::delegate [protected]
 

Usually this is null, but factory method wrapJdkLogger(Logger) could supply this delegate.

LogConfig alma::acs::logging::AcsLogger::logConfig [private]
 

Configuration data. May be null for instances created from non-standard factory methods.

See also:
configureLogging(LogConfig)

final Set<String> alma::acs::logging::AcsLogger::loggerClassNames = new HashSet<String>() [private]
 

the logger class, which must be known to unwind the stack trace. Will be this class unless we use delegation. We don't share this set among Logger instances to avoid threading overheads for fast access.

String alma::acs::logging::AcsLogger::loggerName [private]
 

boolean alma::acs::logging::AcsLogger::noLevelWarningPrinted = false [private]
 

final int alma::acs::logging::AcsLogger::offValue = Level.OFF.intValue() [static, protected]
 

String alma::acs::logging::AcsLogger::processName [private]
 

String alma::acs::logging::AcsLogger::sourceObject [private]
 

TODO: check why we set the SourceObject as a field here, and also take the loggerName in the formatters to fill in the source object field there.


The documentation for this class was generated from the following file:
Generated on Thu Apr 30 02:53:37 2009 for ACS Java API by doxygen 1.3.8