public class AcsLogger extends java.util.logging.Logger implements LogConfigSubscriber
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 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.
| Modifier and Type | Field and Description |
|---|---|
protected java.util.logging.Logger |
delegate
Usually this is null, but factory method
#wrapJdkLogger(Logger) could supply this delegate. |
protected static int |
offValue |
AcsLoggerStatistics |
stats |
| Modifier | Constructor and Description |
|---|---|
|
AcsLogger(java.lang.String name,
java.lang.String resourceBundleName,
LogConfig logConfig)
Standard constructor that configures this logger from
logConfig and also registers for log config
changes. |
protected |
AcsLogger(java.lang.String name,
java.lang.String resourceBundleName,
LogConfig logConfig,
boolean allowNullLogConfig,
java.util.logging.Logger delegate)
Auxiliary ctor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addIgnoreLogs(java.lang.String className,
java.lang.String methodName)
The AcsLogger can be configured to ignore certain logs.
|
void |
addLoggerClass(java.lang.Class<?> loggerClass)
Adds a logger class, which will be used to skip entries in the stack trace until the original logging method is found.
|
void |
closeLogger()
This method is called when the logger is to be closed and will activate any final action
the logger need to perform before liberating resources.
|
void |
configureLogging(LogConfig newLogConfig)
Callback method, configures this logger from the data in logConfig.
|
AcsLogRecord |
createAcsLogRecord(java.util.logging.Level level,
java.lang.String msg) |
static AcsLogger |
createUnconfiguredLogger(java.lang.String name,
java.lang.String resourceBundleName)
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.
|
static AcsLogger |
fromJdkLogger(java.util.logging.Logger logger,
java.lang.String wrapLoggerName)
Client applications that use ACS class
ComponentClient may need to turn their own JDK Logger into
an AcsLogger. |
java.lang.String |
getProcessName() |
java.lang.String |
getSourceObject() |
void |
log(java.util.logging.LogRecord record)
Logs the given
LogRecord. |
void |
logToAudience(java.util.logging.Level level,
java.lang.String msg,
java.lang.String audience)
The audience strings allowed in alma are defined in IDL,
but are available as type-safe enums in
AudienceLogger,
which thus should be preferred over this generic method. |
void |
logToAudience(java.util.logging.Level level,
java.lang.String msg,
java.lang.Throwable thr,
java.lang.String audience)
The audience strings allowed in alma are defined in IDL,
but are available as type-safe enums in
AudienceLogger,
which thus should be preferred over this generic method. |
addHandler, config, config, entering, entering, entering, exiting, exiting, fine, fine, finer, finer, finest, finest, getAnonymousLogger, getAnonymousLogger, getFilter, getGlobal, getHandlers, getLevel, getLogger, getLogger, getName, getParent, getResourceBundle, getResourceBundleName, getUseParentHandlers, info, info, isLoggable, log, log, log, log, log, log, logp, logp, logp, logp, logp, logp, logrb, logrb, logrb, logrb, logrb, logrb, removeHandler, setFilter, setLevel, setParent, setResourceBundle, setUseParentHandlers, severe, severe, throwing, warning, warningprotected static final int offValue
public AcsLoggerStatistics stats
protected final java.util.logging.Logger delegate
#wrapJdkLogger(Logger) could supply this delegate.public AcsLogger(java.lang.String name,
java.lang.String resourceBundleName,
LogConfig logConfig)
logConfig and also registers for log config
changes.name - the logger's nameresourceBundleName - may be nulllogConfig - the ACS logging configuration object, which gives optional access to the CDB.protected AcsLogger(java.lang.String name,
java.lang.String resourceBundleName,
LogConfig logConfig,
boolean allowNullLogConfig,
java.util.logging.Logger delegate)
logConfig - may be null if allowNullLogConfig==truepublic static AcsLogger createUnconfiguredLogger(java.lang.String name, java.lang.String resourceBundleName)
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!
name - the logger's nameresourceBundleName - AcsLogger that is as close to a normal JDK Logger as possible.java.lang.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.public static AcsLogger fromJdkLogger(java.util.logging.Logger logger, java.lang.String wrapLoggerName)
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.
logger - the JDK loggerwrapperName - Name of the returned AcsLogger. May be null in which case the delegate's name plus
"wrapper" is taken.logger.public java.lang.String getProcessName()
public java.lang.String getSourceObject()
public void logToAudience(java.util.logging.Level level,
java.lang.String msg,
java.lang.String audience)
AudienceLogger,
which thus should be preferred over this generic method.public void logToAudience(java.util.logging.Level level,
java.lang.String msg,
java.lang.Throwable thr,
java.lang.String audience)
AudienceLogger,
which thus should be preferred over this generic method.public AcsLogRecord createAcsLogRecord(java.util.logging.Level level, java.lang.String msg)
public void log(java.util.logging.LogRecord record)
LogRecord.
The record can be modified or dropped by the optional filters provided in #addLogRecordFilter(alma.acs.logging.AcsLogger.LogRecordFilter).
Adding of context information:
AcsJException), or
LogRecord.inferCaller(),
but additionally including thread name and line of code.
log in class java.util.logging.LoggerLogger.log(java.util.logging.LogRecord)public void configureLogging(LogConfig newLogConfig)
configureLogging in interface LogConfigSubscriberLogConfigSubscriber.configureLogging(alma.acs.logging.config.LogConfig)public void addLoggerClass(java.lang.Class<?> loggerClass)
loggerClass - public void addIgnoreLogs(java.lang.String className,
java.lang.String methodName)
className - class name where the log comes from. Must not be null.methodName - method name where the log comes from. Must not be null.public void closeLogger()