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

alma::acs::logging::config::LogConfig Class Reference

List of all members.

Public Member Functions

 LogConfig ()
void setCDB (DALOperations cdb)
void setCDBLoggingConfigPath (String path)
void setCDBComponentPath (String compLoggerName, String path)
void initialize (boolean cdbBeatsProperties) throws LogConfigException
String getCentralizedLogger ()
int getDispatchPacketSize ()
AcsLogLevelDefinition getImmediateDispatchLevel ()
int getFlushPeriodSeconds ()
int getMaxLogQueueSize ()
AcsLogLevelDefinition getDefaultMinLogLevelLocal ()
void setDefaultMinLogLevelLocal (AcsLogLevelDefinition newLevel)
AcsLogLevelDefinition getDefaultMinLogLevel ()
void setDefaultMinLogLevel (AcsLogLevelDefinition newLevel)
Set< String > getLoggerNames ()
boolean isKnownLogger (String loggerName)
boolean hasCustomConfig (String loggerName)
LockableUnnamedLogger getNamedLoggerConfig (String loggerName)
void setNamedLoggerConfig (String loggerName, LockableUnnamedLogger config) throws AcsJIllegalArgumentEx
void setNamedLoggerConfig (String loggerName, UnnamedLogger config) throws AcsJIllegalArgumentEx
void clearNamedLoggerConfig (String loggerName)
void setMinLogLevelLocal (AcsLogLevelDefinition newLevel, String loggerName)
void setMinLogLevel (AcsLogLevelDefinition newLevel, String loggerName)
void setAndLockMinLogLevel (AcsLogLevelDefinition newLevel, String loggerName)
boolean renameNamedLoggerConfig (String oldLoggerName, String newLoggerName)
void addSubscriber (LogConfigSubscriber subscriber)
void removeSubscriber (LogConfigSubscriber subscriber)
void setInternalLogger (Logger logger)

Static Public Attributes

final String PROPERTYNAME_MIN_LOG_LEVEL_LOCAL = "ACS.logstdout"
final String PROPERTYNAME_MIN_LOG_LEVEL = "ACS.log.minlevel.remote"

Protected Member Functions

void log (Level level, String msg, Throwable thr)

Package Functions

String getLogConfigXml (String cdbPathParent, String xpathLogConfigNode) throws CDBXMLErrorEx, CDBRecordDoesNotExistEx, ParserConfigurationException, SAXException, IOException, XPathExpressionException, TransformerException
void notifySubscribers ()

Static Package Attributes

final String CDBNAME_LoggingConfig = LoggingConfig.class.getSimpleName()
final String CDBNAME_ComponentLogger = "ComponentLogger"

Private Member Functions

void configureDefaultLevelsFromProperties ()
AcsLogLevelDefinition convertLegalLogLevel (LogLevel legalLogLevel)
void storeNamedLoggerConfig (String loggerName, LockableUnnamedLogger config)

Private Attributes

Logger logger
DALOperations cdb
String cdbLoggingConfigPath
Map< String, String > cdbComponentPaths
LoggingConfig loggingConfig
final Map< String, LockableUnnamedLoggernamedLoggerConfigs
final List< LogConfigSubscribersubscriberList

Detailed Description

Class that encapsulates all configuration sources (defaults, properties, CDB) for Java logging, and supports runtime updates of logging configuration based on these sources. This class can be used by a process such as the Java container or the manager, in order to configure all its loggers (e.g. container logger, component loggers, ORB logger).
Author:
hsommer


Constructor & Destructor Documentation

alma::acs::logging::config::LogConfig::LogConfig  )  [inline]
 


Member Function Documentation

void alma::acs::logging::config::LogConfig::addSubscriber LogConfigSubscriber  subscriber  )  [inline]
 

void alma::acs::logging::config::LogConfig::clearNamedLoggerConfig String  loggerName  )  [inline]
 

Clears log level settings for the given named logger, so that it uses default log levels. Notifies all listeners. Ignores this call if loggerName is null.

void alma::acs::logging::config::LogConfig::configureDefaultLevelsFromProperties  )  [inline, private]
 

Reads the properties ACS.logstdout (name defined as PROPERTYNAME_MIN_LOG_LEVEL) and ACS.log.minlevel.remote (name defined as PROPERTYNAME_MIN_LOG_LEVEL_LOCAL) and, if the property is defined, sets the respective default level. Prior values are lost.

AcsLogLevelDefinition alma::acs::logging::config::LogConfig::convertLegalLogLevel LogLevel  legalLogLevel  )  [inline, private]
 

Helper method that converts an integer log level to the matching enum literal. It suppresses the AcsJIllegalArgumentEx because the level must have been validated during the config init (and we wouldn't be bothered about exceptions here if we had stored the converted enum literal instead of the castor class). Therefore a lame log and runtime ex are thrown just in case, but no AcsJIllegalArgumentEx gets thrown on.

String alma::acs::logging::config::LogConfig::getCentralizedLogger  )  [inline]
 

AcsLogLevelDefinition alma::acs::logging::config::LogConfig::getDefaultMinLogLevel  )  [inline]
 

Gets the log level for centralized logging for default loggers (those that don't have custom levels set).

AcsLogLevelDefinition alma::acs::logging::config::LogConfig::getDefaultMinLogLevelLocal  )  [inline]
 

Gets the log level for stdout printing for default loggers (those that don't have custom levels set).

int alma::acs::logging::config::LogConfig::getDispatchPacketSize  )  [inline]
 

int alma::acs::logging::config::LogConfig::getFlushPeriodSeconds  )  [inline]
 

AcsLogLevelDefinition alma::acs::logging::config::LogConfig::getImmediateDispatchLevel  )  [inline]
 

String alma::acs::logging::config::LogConfig::getLogConfigXml String  cdbPathParent,
String  xpathLogConfigNode
throws CDBXMLErrorEx, CDBRecordDoesNotExistEx, ParserConfigurationException, SAXException, IOException, XPathExpressionException, TransformerException [inline, package]
 

Reads the CDB element from the given path as XML, and extracts the child element that must be uniquely identified by the XPath expression in xpathLogConfigNode.

TODO: move the Node-to-XML-String code to a general utility package and return just the Node -- any client can then easily turn it into a String if needed. For Castor-parsing, a node is fine, see Unmarshaller#unmarshal(Node).

Parameters:
cdbPathParent path to container, manager, or component config node
xpathExpression For example, for containers and managers //LoggingConfig, for multiple-components-xml //_[='myCompName']/ComponentLogger
Returns:
XML String for the requested child, or null if no unique xml child element was found.
Exceptions:
CDBRecordDoesNotExistEx 
CDBXMLErrorEx 
ParserConfigurationException 
IOException 
SAXException 
XPathExpressionException 
TransformerException 
IllegalStateException if the cdb ref has not been set

Set<String> alma::acs::logging::config::LogConfig::getLoggerNames  )  [inline]
 

Gets the names of all known loggers, no matter if they use default or custom levels.

The loggers are registered automatically by calls to getNamedLoggerConfig(String) and setNamedLoggerConfig(String, UnnamedLogger).

int alma::acs::logging::config::LogConfig::getMaxLogQueueSize  )  [inline]
 

LockableUnnamedLogger alma::acs::logging::config::LogConfig::getNamedLoggerConfig String  loggerName  )  [inline]
 

Gets the (log level) configuration data for a named logger. Resorts to the default configuration if a specialized configuration is not available.

Note that a copy of the config data is returned, so changes to it will not affect any other object's configuration.

A previously unknown logger gets registered by its name. If this is not intended, check first with isKnownLogger(String).

boolean alma::acs::logging::config::LogConfig::hasCustomConfig String  loggerName  )  [inline]
 

Checks if there is a level configuration for this particular logger.

Parameters:
loggerName 
Returns:
false if the logger is not known or uses the default configuration

void alma::acs::logging::config::LogConfig::initialize boolean  cdbBeatsProperties  )  throws LogConfigException [inline]
 

Initializes the values based on CDB settings, logging properties, etc. All subscribing classes are notified of the new configuration, see LogConfigSubscriber#configureLogging(LogConfig).

This method can be called more than once: if some settings have changed, should be read in, and the logging classes should be notified of these changes. For example, the container could call this method when it gets notified that the logging configuration in the CDB has been changed at runtime.

Parameters:
cdbBeatsProperties if true then the default logger level values from the CDB override the properties (env vars). True is foreseen for dynamic updates from the CDB, whereas for the initial configuration it should be a false.
Exceptions:
LogConfigException if reading the configuration data failed and thus default values were used, or if there were problems during configuration even though some of the configuring went ok (best-effort approach).

boolean alma::acs::logging::config::LogConfig::isKnownLogger String  loggerName  )  [inline]
 

Checks if the given logger name is known, either for default or custom config.

The current LoggingConfigurable interface semantics don't allow configuration of a logger that does not yet exist. Therefore this method can be used to check first before calling getNamedLoggerConfig(String) or setNamedLoggerConfig(String, alma.acs.logging.config.LogConfig.LockableUnnamedLogger), which would automatically add a previously unknown logger.

Parameters:
loggerName 
Since:
ACS 7.0.2

void alma::acs::logging::config::LogConfig::log Level  level,
String  msg,
Throwable  thr
[inline, protected]
 

Logs to the Logger given in setInternalLogger(Logger), or to System.out if no Logger has been provided.

void alma::acs::logging::config::LogConfig::notifySubscribers  )  [inline, package]
 

void alma::acs::logging::config::LogConfig::removeSubscriber LogConfigSubscriber  subscriber  )  [inline]
 

boolean alma::acs::logging::config::LogConfig::renameNamedLoggerConfig String  oldLoggerName,
String  newLoggerName
[inline]
 

Renaming of a logger can occur for example when an ORB logger undergoes a name change as soon as the process name is determined by the container logger.

Renaming is not a regular part of a logger's life though. By the time that tools can look at the list of loggers, no renaming should occur any more.

Parameters:
oldLoggerName 
newLoggerName 
Returns:
true if the logger config was renamed. False for bad or unmatching parameters which result in no change.

void alma::acs::logging::config::LogConfig::setAndLockMinLogLevel AcsLogLevelDefinition  newLevel,
String  loggerName
[inline]
 

Locking a remote log level is currently needed only for the container to ensure that the ORB logger of the container in which the archive logger component runs is guaranteed to not produce any logs (which would lead to log record explosion through positive feedback).

The more abstract concept of locking log levels was chosen to keep the special scenario described above out of the logging config code.

Parameters:
newLevel small integer log level (IDL value wrapped by a Java enum)
loggerName 

void alma::acs::logging::config::LogConfig::setCDB DALOperations  cdb  )  [inline]
 

Sets the reference to the CDB, which will then be used for configuration. Before this method is called, default values are used instead of CDB values.

Note that the reference is only set, but the CDB is not read automatically; for this, call initialize(boolean).

Parameters:
cdb a reference to the CDB. Will be ignored if == null.

void alma::acs::logging::config::LogConfig::setCDBComponentPath String  compLoggerName,
String  path
[inline]
 

Sets the path to the CDB's node that is parent of the <log:UnnamedLogger/> component logger node. This call does not access the CDB.

Parameters:
compLoggerName the component logger name, e.g. MOUNT1.
path e.g. MACI/Components.

void alma::acs::logging::config::LogConfig::setCDBLoggingConfigPath String  path  )  [inline]
 

Sets the path to the CDB's node that is parent of the <LoggingConfig> node, such as a container or the manager node. This call does not access the CDB.

Parameters:
path for example "MACI/Containers/frodoContainer"

void alma::acs::logging::config::LogConfig::setDefaultMinLogLevel AcsLogLevelDefinition  newLevel  )  [inline]
 

Sets the given log level for centralized logging of log records for all loggers that don't have a custom configuration. All log config listeners.get notified of this change. The call is ignored for negative values of newLevel.

Parameters:
newLevel 

void alma::acs::logging::config::LogConfig::setDefaultMinLogLevelLocal AcsLogLevelDefinition  newLevel  )  [inline]
 

Sets the given log level for stdout printing of log records for all loggers that don't have a custom configuration. All log config listeners.get notified of this change. The call is ignored for negative values of newLevel.

Parameters:
newLevel 

void alma::acs::logging::config::LogConfig::setInternalLogger Logger  logger  )  [inline]
 

Sets the Logger to be used by this class and dependent classes for internal tracing.

Note that in the current design of ClientLogManager and LogConfig, the Logger can not be provided already in the constructor, because the Logger first must be configured, which in turn requires a LogConfig instance. That's why we have this setter method.

void alma::acs::logging::config::LogConfig::setMinLogLevel AcsLogLevelDefinition  newLevel,
String  loggerName
[inline]
 

void alma::acs::logging::config::LogConfig::setMinLogLevelLocal AcsLogLevelDefinition  newLevel,
String  loggerName
[inline]
 

void alma::acs::logging::config::LogConfig::setNamedLoggerConfig String  loggerName,
UnnamedLogger  config
throws AcsJIllegalArgumentEx [inline]
 

We keep this method next to setNamedLoggerConfig(String, alma.acs.logging.config.LogConfig.LockableUnnamedLogger) in order to keep the LockableUnnamedLogger confined to this class. It may be exposed later, and this method could then be removed.

Parameters:
loggerName 
config 
Since:
ACS 7.0

void alma::acs::logging::config::LogConfig::setNamedLoggerConfig String  loggerName,
LockableUnnamedLogger  config
throws AcsJIllegalArgumentEx [inline]
 

Sets the given log levels for the named logger and notifies all listeners. Ignores this call if any of the parameters are null.

A copy of the supplied config is made to isolate the stored data from later modifications.

If loggerName is previously unknown, then this logger is added automatically to the list of known loggers. If this is not intended, check first using isKnownLogger(String).

Exceptions:
AcsJIllegalArgumentEx if the log level integers inside config are illegal.

void alma::acs::logging::config::LogConfig::storeNamedLoggerConfig String  loggerName,
LockableUnnamedLogger  config
[inline, private]
 

Method that guards namedLoggerConfigs.put(loggerName, config) and denies access if the old config is locked.

Parameters:
loggerName logger name, must not be null
config new level values, or null to "link" to default log levels.
See also:
namedLoggerConfigs


Member Data Documentation

DALOperations alma::acs::logging::config::LogConfig::cdb [private]
 

The ACS CDB. This value is null unless it gets set in setCDB(DAL).

Map<String, String> alma::acs::logging::config::LogConfig::cdbComponentPaths [private]
 

Paths in the CDB to the element that contains component configuration with child elements of type UnnamedLogger. key = component logger name, value = path in the CDB to the Component configuration. Note that log levels given in the component configuration get overridden by named logger levels found in the container configuration, in case of conflicts.

This only applies to container log config, since for example the manager logging config does not deal with components.

String alma::acs::logging::config::LogConfig::cdbLoggingConfigPath [private]
 

Path in the CDB to the element (container, manager etc) that contains a LoggingConfig child. From here we get process-wide settings, default log levels, and optional named logger levels. Note that named logger levels found here override those in cdbComponentPaths in case of conflict.

final String alma::acs::logging::config::LogConfig::CDBNAME_ComponentLogger = "ComponentLogger" [static, package]
 

In CDB queries for the ComponentLogger child of a component configuration we need the "LoggingConfig" string.

In the schema Components.xsd we are interested in the grand-child element ComponentLogger. The generated Java class corresponds to the type UnnamedLogger though. The element name is only present in the method name alma.maci.componentconfig.components.ComponentInfo#getComponentLogger which cannot be used to define a constant. Therefore we hardcode the name here.

final String alma::acs::logging::config::LogConfig::CDBNAME_LoggingConfig = LoggingConfig.class.getSimpleName() [static, package]
 

In CDB queries for the LoggingConfig child of a container or manager configuration we need the "LoggingConfig" string.

For type safety we get that name from the schema-generated castor class.

Logger alma::acs::logging::config::LogConfig::logger [private]
 

The logger for messages logged by this class. Note that this field will be null at first, until the Logger gets provided, so better use log(Level, String, Throwable) for safe access.

LoggingConfig alma::acs::logging::config::LogConfig::loggingConfig [private]
 

The schema-generated logging config, either with default values, or read from the CDB. The log levels can also be changed by properties (env var peers) and dynamically.

final Map<String, LockableUnnamedLogger> alma::acs::logging::config::LogConfig::namedLoggerConfigs [private]
 

Logger names and optionally associated log levels. Loggers that use default levels are stored with their name (map key), but a null value for the configuration is associated with them.

Actual named logger configurations are stored as the map values, and can come from

key = [String] logger name, value = [LockableUnnamedLogger or null] level config

final String alma::acs::logging::config::LogConfig::PROPERTYNAME_MIN_LOG_LEVEL = "ACS.log.minlevel.remote" [static]
 

final String alma::acs::logging::config::LogConfig::PROPERTYNAME_MIN_LOG_LEVEL_LOCAL = "ACS.logstdout" [static]
 

final List<LogConfigSubscriber> alma::acs::logging::config::LogConfig::subscriberList [private]
 

Subscribers get notified of logging config changes


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