Classes | Public Member Functions | Static Public Attributes | Protected Member Functions | Package Functions | Static Package Attributes

alma.acs.logging.config.LogConfig Class Reference

List of all members.

Classes

class  LockableUnnamedLogger

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 ()
int getMaxLogsPerSecond ()
void setMaxLogsPerSecond (int maxLogsPerSecond)
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

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

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

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

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 (  ) 

Member Function Documentation

void alma.acs.logging.config.LogConfig.addSubscriber ( LogConfigSubscriber  subscriber  ) 
void alma.acs.logging.config.LogConfig.clearNamedLoggerConfig ( String  loggerName  ) 

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.

References alma.acs.logging.config.LogConfig.notifySubscribers().

Referenced by com.cosylab.acs.maci.plug.ManagerProxyImpl.set_logLevels(), and alma.acs.container.AcsContainer.set_logLevels().

String alma.acs.logging.config.LogConfig.getCentralizedLogger (  ) 
AcsLogLevelDefinition alma.acs.logging.config.LogConfig.getDefaultMinLogLevel (  ) 

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

Referenced by com.cosylab.acs.maci.plug.ManagerProxyImpl.get_default_logLevels(), alma.acs.container.AcsContainer.get_default_logLevels(), and alma.acs.logging.ClientLogManager.getLoggerForCorba().

AcsLogLevelDefinition alma.acs.logging.config.LogConfig.getDefaultMinLogLevelLocal (  ) 
int alma.acs.logging.config.LogConfig.getDispatchPacketSize (  ) 
int alma.acs.logging.config.LogConfig.getFlushPeriodSeconds (  ) 
AcsLogLevelDefinition alma.acs.logging.config.LogConfig.getImmediateDispatchLevel (  ) 
String alma.acs.logging.config.LogConfig.getLogConfigXml ( String  cdbPathParent,
String  xpathLogConfigNode 
) throws CDBXMLErrorEx, CDBRecordDoesNotExistEx, ParserConfigurationException, SAXException, IOException, XPathExpressionException, TransformerException [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

References alma.acs.logging.config.LogConfig.log().

Referenced by alma.acs.logging.config.LogConfig.initialize().

Set<String> alma.acs.logging.config.LogConfig.getLoggerNames (  ) 

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).

Referenced by com.cosylab.acs.maci.plug.ManagerProxyImpl.get_logger_names(), and alma.acs.container.AcsContainer.get_logger_names().

int alma.acs.logging.config.LogConfig.getMaxLogQueueSize (  ) 
int alma.acs.logging.config.LogConfig.getMaxLogsPerSecond (  ) 
LockableUnnamedLogger alma.acs.logging.config.LogConfig.getNamedLoggerConfig ( String  loggerName  ) 

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).

Referenced by alma.acs.logging.StdOutConsoleHandler.configureLogging(), alma.acs.logging.AcsLoggingHandler.configureLogging(), alma.acs.logging.AcsLogger.configureLogging(), com.cosylab.acs.maci.plug.ManagerProxyImpl.get_logLevels(), alma.acs.container.AcsContainer.get_logLevels(), alma.acs.logging.ClientLogManager.getLoggerForApplication(), alma.acs.container.AcsContainer.ping(), alma.acs.logging.config.LogConfig.setAndLockMinLogLevel(), alma.acs.logging.config.LogConfig.setMinLogLevel(), and alma.acs.logging.config.LogConfig.setMinLogLevelLocal().

boolean alma.acs.logging.config.LogConfig.hasCustomConfig ( String  loggerName  ) 

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

Referenced by com.cosylab.acs.maci.plug.ManagerProxyImpl.get_logLevels(), alma.acs.container.AcsContainer.get_logLevels(), and alma.acs.logging.ClientLogManager.getLoggerForCorba().

void alma.acs.logging.config.LogConfig.initialize ( boolean  cdbBeatsProperties  )  throws LogConfigException

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).

References alma.acs.logging.config.LogConfig.CDBNAME_ComponentLogger, alma.acs.logging.config.LogConfig.CDBNAME_LoggingConfig, alma.acs.logging.config.LogConfig.getLogConfigXml(), org.exolab.castor.core.exceptions.CastorException.getMessage(), alma.acs.logging.config.LogConfig.log(), and alma.acs.logging.config.LogConfig.notifySubscribers().

Referenced by alma.acs.logging.ClientLogManager.ClientLogManager(), alma.acs.container.AcsContainer.initialize(), com.cosylab.acs.maci.plug.ManagerProxyImpl.refresh_logging_config(), and alma.acs.container.AcsContainer.refresh_logging_config().

boolean alma.acs.logging.config.LogConfig.isKnownLogger ( String  loggerName  ) 

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 
) [protected]
void alma.acs.logging.config.LogConfig.notifySubscribers (  )  [package]
void alma.acs.logging.config.LogConfig.removeSubscriber ( LogConfigSubscriber  subscriber  ) 
boolean alma.acs.logging.config.LogConfig.renameNamedLoggerConfig ( String  oldLoggerName,
String  newLoggerName 
)

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.

Referenced by alma.acs.logging.AcsLogger.setLoggerName().

void alma.acs.logging.config.LogConfig.setAndLockMinLogLevel ( AcsLogLevelDefinition  newLevel,
String  loggerName 
)

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 

References alma.acs.logging.config.LogConfig.getNamedLoggerConfig(), alma.acs.logging.config.LogConfig.log(), and alma.acs.logging.config.LogConfig.setNamedLoggerConfig().

Referenced by alma.acs.logging.ClientLogManager.getLoggerForCorba(), and alma.acs.logging.ClientLogManager.suppressCorbaRemoteLogging().

void alma.acs.logging.config.LogConfig.setCDB ( DALOperations  cdb  ) 

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.

References alma.acs.logging.config.LogConfig.log().

Referenced by alma.acs.container.AcsContainer.initialize().

void alma.acs.logging.config.LogConfig.setCDBComponentPath ( String  compLoggerName,
String  path 
)

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  ) 

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"

Referenced by alma.acs.container.AcsContainer.initialize().

void alma.acs.logging.config.LogConfig.setDefaultMinLogLevel ( AcsLogLevelDefinition  newLevel  ) 

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 

References alma.acs.logging.config.LogConfig.notifySubscribers().

Referenced by com.cosylab.acs.maci.plug.ManagerProxyImpl.set_default_logLevels(), and alma.acs.container.AcsContainer.set_default_logLevels().

void alma.acs.logging.config.LogConfig.setDefaultMinLogLevelLocal ( AcsLogLevelDefinition  newLevel  ) 

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 

References alma.acs.logging.config.LogConfig.notifySubscribers().

Referenced by com.cosylab.acs.maci.plug.ManagerProxyImpl.set_default_logLevels(), and alma.acs.container.AcsContainer.set_default_logLevels().

void alma.acs.logging.config.LogConfig.setInternalLogger ( Logger  logger  ) 

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.

Referenced by alma.acs.logging.ClientLogManager.ClientLogManager().

void alma.acs.logging.config.LogConfig.setMaxLogsPerSecond ( int  maxLogsPerSecond  ) 

Limits the total number of logs emitted by the whole process, separately for local and remote logging.

Introduced with ACS 9.0 for only reading the log throttle configuration data, we add this setter method in preparation for future exposure in the LoggingConfigurable interface, and also for test setups.

References alma.acs.logging.config.LogConfig.notifySubscribers().

void alma.acs.logging.config.LogConfig.setMinLogLevel ( AcsLogLevelDefinition  newLevel,
String  loggerName 
)
void alma.acs.logging.config.LogConfig.setMinLogLevelLocal ( AcsLogLevelDefinition  newLevel,
String  loggerName 
)
void alma.acs.logging.config.LogConfig.setNamedLoggerConfig ( String  loggerName,
LockableUnnamedLogger  config 
) throws AcsJIllegalArgumentEx

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.

References alma.acs.logging.config.LogConfig.notifySubscribers().

Referenced by com.cosylab.acs.maci.plug.ManagerProxyImpl.set_logLevels(), alma.acs.container.AcsContainer.set_logLevels(), alma.acs.logging.config.LogConfig.setAndLockMinLogLevel(), alma.acs.logging.config.LogConfig.setMinLogLevel(), alma.acs.logging.config.LogConfig.setMinLogLevelLocal(), and alma.acs.logging.config.LogConfig.setNamedLoggerConfig().

void alma.acs.logging.config.LogConfig.setNamedLoggerConfig ( String  loggerName,
UnnamedLogger  config 
) throws AcsJIllegalArgumentEx

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

References alma.acs.logging.config.LogConfig.setNamedLoggerConfig().


Member Data Documentation

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.

Referenced by alma.acs.logging.config.LogConfig.initialize().

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.

Referenced by alma.acs.logging.config.LogConfig.initialize().

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

Using this property, we can configure named loggers for processes other than containers and manager, for which there is no logging configuration in the CDB. It is not expected to be used widely, which excuses the not so intuitive stuffing of data into a single property.

Example:

-DACS.log.minlevel.namedloggers="hibernateSQL@CDB-RDB=2,3:hibernate@CDB-RDB=5,5"

configures two loggers: "hibernateSQL@CDB-RDB" will use local log level 2 and remote level 3, while "hibernate@CDB-RDB" will use local and remote level 5.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations Properties