public class LogConfig
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
LogConfig.LockableUnnamedLogger |
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
PROPERTYNAME_MIN_LOG_LEVEL |
static java.lang.String |
PROPERTYNAME_MIN_LOG_LEVEL_LOCAL |
static java.lang.String |
PROPERTYNAME_NAMED_LOGGER_LEVELS
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.
|
| Constructor and Description |
|---|
LogConfig() |
| Modifier and Type | Method and Description |
|---|---|
void |
addSubscriber(LogConfigSubscriber subscriber) |
void |
clearNamedLoggerConfig(java.lang.String loggerName)
Clears log level settings for the given named logger,
so that it uses default log levels.
|
java.lang.String |
getCentralizedLogger() |
AcsLogLevelDefinition |
getDefaultMinLogLevel()
Gets the log level for centralized logging for default loggers
(those that don't have custom levels set).
|
AcsLogLevelDefinition |
getDefaultMinLogLevelLocal()
Gets the log level for stdout printing for default loggers
(those that don't have custom levels set).
|
int |
getDispatchPacketSize() |
int |
getFlushPeriodSeconds() |
AcsLogLevelDefinition |
getImmediateDispatchLevel() |
java.util.Set<java.lang.String> |
getLoggerNames()
Gets the names of all known loggers, no matter if they use default or custom levels.
|
int |
getMaxLogQueueSize() |
int |
getMaxLogsPerSecond() |
LogConfig.LockableUnnamedLogger |
getNamedLoggerConfig(java.lang.String loggerName)
Gets the (log level) configuration data for a named logger.
|
boolean |
hasCustomConfig(java.lang.String loggerName)
Checks if there is a level configuration for this particular logger.
|
void |
initialize(boolean cdbBeatsProperties)
Initializes the values based on CDB settings, logging properties, etc.
|
boolean |
isKnownLogger(java.lang.String loggerName)
Checks if the given logger name is known, either for default or custom config.
|
protected void |
log(java.util.logging.Level level,
java.lang.String msg,
java.lang.Throwable thr)
Logs to the Logger given in
setInternalLogger(Logger), or to System.out if no Logger has been provided. |
void |
removeSubscriber(LogConfigSubscriber subscriber) |
boolean |
renameNamedLoggerConfig(java.lang.String oldLoggerName,
java.lang.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.
|
void |
setAndLockMinLogLevel(AcsLogLevelDefinition newLevel,
java.lang.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).
|
void |
setCDB(DALOperations cdb)
Sets the reference to the CDB, which will then be used for configuration.
|
void |
setCDBComponentPath(java.lang.String compLoggerName,
java.lang.String path)
Sets the path to the CDB's node that is parent of the
<log:UnnamedLogger/> component logger node.
|
void |
setCDBLoggingConfigPath(java.lang.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.
|
void |
setDefaultMinLogLevel(AcsLogLevelDefinition newLevel)
Sets the given log level for centralized logging of log records
for all loggers that don't have a custom configuration.
|
void |
setDefaultMinLogLevelLocal(AcsLogLevelDefinition newLevel)
Sets the given log level for stdout printing of log records
for all loggers that don't have a custom configuration.
|
void |
setInternalLogger(java.util.logging.Logger logger)
Sets the Logger to be used by this class and dependent classes for internal tracing.
|
void |
setMaxLogsPerSecond(int maxLogsPerSecond)
Limits the total number of logs emitted by the whole process,
separately for local and remote logging.
|
void |
setMinLogLevel(AcsLogLevelDefinition newLevel,
java.lang.String loggerName) |
void |
setMinLogLevelLocal(AcsLogLevelDefinition newLevel,
java.lang.String loggerName) |
void |
setNamedLoggerConfig(java.lang.String loggerName,
LogConfig.LockableUnnamedLogger config)
Sets the given log levels for the named logger and notifies all listeners.
|
void |
setNamedLoggerConfig(java.lang.String loggerName,
UnnamedLogger config)
We keep this method next to
setNamedLoggerConfig(String, alma.acs.logging.config.LogConfig.LockableUnnamedLogger)
in order to keep the LockableUnnamedLogger confined to this class. |
public static final java.lang.String PROPERTYNAME_MIN_LOG_LEVEL_LOCAL
public static final java.lang.String PROPERTYNAME_MIN_LOG_LEVEL
public static final java.lang.String PROPERTYNAME_NAMED_LOGGER_LEVELS
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.
public void setCDB(DALOperations cdb)
Note that the reference is only set, but the CDB is not read
automatically; for this, call initialize(boolean).
cdb - a reference to the CDB. Will be ignored if == null.public void setCDBLoggingConfigPath(java.lang.String path)
path - for example "MACI/Containers/frodoContainer"public void setCDBComponentPath(java.lang.String compLoggerName,
java.lang.String path)
compLoggerName - the component logger name, e.g. MOUNT1.path - e.g. MACI/Components.public void initialize(boolean cdbBeatsProperties)
throws LogConfigException
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.
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.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).public java.lang.String getCentralizedLogger()
public int getDispatchPacketSize()
public AcsLogLevelDefinition getImmediateDispatchLevel()
public int getFlushPeriodSeconds()
public int getMaxLogQueueSize()
public int getMaxLogsPerSecond()
public void setMaxLogsPerSecond(int maxLogsPerSecond)
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.
public AcsLogLevelDefinition getDefaultMinLogLevelLocal()
public void setDefaultMinLogLevelLocal(AcsLogLevelDefinition newLevel)
newLevel.newLevel - public AcsLogLevelDefinition getDefaultMinLogLevel()
public void setDefaultMinLogLevel(AcsLogLevelDefinition newLevel)
newLevel.newLevel - public java.util.Set<java.lang.String> getLoggerNames()
The loggers are registered automatically by calls to
getNamedLoggerConfig(String) and setNamedLoggerConfig(String, UnnamedLogger).
public boolean isKnownLogger(java.lang.String loggerName)
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.
loggerName - public boolean hasCustomConfig(java.lang.String loggerName)
loggerName - public LogConfig.LockableUnnamedLogger getNamedLoggerConfig(java.lang.String loggerName)
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).
public void setNamedLoggerConfig(java.lang.String loggerName,
LogConfig.LockableUnnamedLogger config)
throws AcsJIllegalArgumentEx
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).
AcsJIllegalArgumentEx - if the log level integers inside config are illegal.public void setNamedLoggerConfig(java.lang.String loggerName,
UnnamedLogger config)
throws AcsJIllegalArgumentEx
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.loggerName - config - AcsJIllegalArgumentExpublic void clearNamedLoggerConfig(java.lang.String loggerName)
loggerName is null.public void setMinLogLevelLocal(AcsLogLevelDefinition newLevel, java.lang.String loggerName)
public void setMinLogLevel(AcsLogLevelDefinition newLevel, java.lang.String loggerName)
public void setAndLockMinLogLevel(AcsLogLevelDefinition newLevel, java.lang.String loggerName)
The more abstract concept of locking log levels was chosen to keep the special scenario described above out of the logging config code.
newLevel - small integer log level (IDL value wrapped by a Java enum)loggerName - public boolean renameNamedLoggerConfig(java.lang.String oldLoggerName,
java.lang.String newLoggerName)
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.
oldLoggerName - newLoggerName - public void addSubscriber(LogConfigSubscriber subscriber)
public void removeSubscriber(LogConfigSubscriber subscriber)
public void setInternalLogger(java.util.logging.Logger logger)
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.
protected void log(java.util.logging.Level level,
java.lang.String msg,
java.lang.Throwable thr)
setInternalLogger(Logger), or to System.out if no Logger has been provided.