Public Types | |
enum | LoggerOwnerType { ContainerLogger, ComponentLogger, OrbLogger, OtherLogger, UnknownLogger } |
Public Member Functions | |
void | configureLogging (LogConfig logConfig) |
LogConfig | getLogConfig () |
boolean | initRemoteLogging (ORB orb, Manager manager, int managerHandle, boolean retry) |
void | suppressRemoteLogging () |
void | suppressCorbaRemoteLogging () |
AcsLogger | getLoggerForCorba (String corbaName, boolean autoConfigureContextName) |
AcsLogger | getLoggerForContainer (String containerName) |
AcsLogger | getLoggerForComponent (String componentName) |
AcsLogger | getLoggerForApplication (String loggerName, boolean enableRemoteLogging) |
void | shutdown (boolean wait) |
void | flushAll () |
Static Public Member Functions | |
synchronized ClientLogManager | getAcsLogManager () |
Protected Member Functions | |
ClientLogManager () | |
void | prepareRemoteLogging () |
void | disableRemoteLogging () |
LogOperations | getLogService (Manager manager, int managerHandle) throws ComponentNotAlreadyActivatedEx, CannotGetComponentEx, NoPermissionEx, ComponentConfigurationNotFoundEx |
Protected Attributes | |
volatile DispatchingLogQueue | logQueue |
Package Types | |
Private Member Functions | |
AcsLoggingHandler | addRemoteHandler (AcsLogger logger) |
StdOutConsoleHandler | addLocalHandler (AcsLogger logger) |
AcsLogger | getAcsLogger (String loggerName, LoggerOwnerType loggerOwnerType) |
void | setProcessName (String processName) |
Private Attributes | |
final LogConfig | sharedLogConfig |
volatile String | logServiceName |
volatile int | flushPeriodSeconds |
final Map< String, AcsLoggerInfo > | loggers = new HashMap<String AcsLoggerInfo>() |
Logger | parentRemoteLogger |
final ReentrantLock | logQueueLock = new ReentrantLock() |
RemoteLogDispatcher | logDispatcher |
final Logger | m_internalLogger |
boolean | DEBUG = Boolean.getBoolean("alma.acs.logging.verbose") |
boolean | LOG_BIN_TYPE = Boolean.getBoolean("ACS.loggingBin") |
String | processName |
final ReentrantLock | processNameLock = new ReentrantLock() |
volatile boolean | suppressCorbaRemoteLogging = false |
Static Private Attributes | |
volatile ClientLogManager | s_instance |
To set the policy for remote logging, either initRemoteLogging(ORB, Manager, int, boolean) or suppressRemoteLogging() must be called. As long as none of these methods are called, it is assumed that remote logging will be initialized at some point later, and all log messages that are meant for remote logging will be stored in a queue. suppressRemoteLogging
will throw away this queue, while initRemoteLogging
will send all queued log records to the remote logger.
Since ACS 7.0, this class acts pretty much as a replacement for the JDK's LogManager and the AcsLogManager} subclass.
If needed, we should investigate how to support the JMX logger management via java.util.logging.LoggingMXBean} which is useless now.
|
|
|
|
|
Adds a local logging handler to the provided logger. Unlike with remote handlers in prepareRemoteLogging(), for local handlers we don't allow removing and re-adding the handlers later.
Note that this method does not require
|
|
Attaches a remote log handler to the given logger, if remote logging has not been suppressed.
Note that this method does not require
|
|
|
|
Removes, closes, and nulls all remote handlers, so that no more records are put into the queue, and queue and remote handlers can be garbage collected.
GC of the queue can be an advantage when logs have been queued for remote sending, but then instead of connecting to the remote logger, we get a call to suppressRemoteLogging(). All messages have been logged locally anyway, so in this case we want to clean up all these |
|
Flushes the remote log queue completely and returns only when it's done. |
|
Creates or reuses a logger, normally with both a local and a remote handler attached. If remote logging is suppressed then no remote handler is attached.
Logger names must be unique. If the requested logger name matches a given logger of the same LoggerOwnerType then that logger is returned. If however a logger of a different type is matched, then a name uniqueness violation is avoided by appending small integer numbers to the logger name. Therefore the name of the returned Logger may be different from
|
|
Singleton accessor. TODO: rename, because now that we have class AcsLogManager, this method name is confusing.
|
|
Gets the |
|
Gets a logger for an application (which is not an ACS component itself), e.g. a GUI application using the ACS ComponentClient.
|
|
Gets a logger object to be used by a component.
This method is not supposed to be accessed directly in the component implementation. Instead, the implementation of
|
|
Gets a logger to be used by the Java container classes. The logger is connected to the central ACS logger. |
|
Gets a logger to be used by ORB and POA classes. The logger is connected to the central ACS logger.
|
|
This method is broken out from initRemoteLogging(ORB, Manager, int, boolean) to allow mock implementation by tests without a functional manager object. Note that module acsjlog comes before jmanager. Reimplemented in alma::acs::logging::RemoteLoggingTest::ClientLogManagerStandalone.
|
|
Enables loggers to send log records to the central ACS logger service. Tries to connect to the log service using the supplied ACS manager. As long as this connection fails, this method can sleep for 10 seconds and then try to connect again, if the parameter Execution time can be significant, so consider calling this method in a separate thread (which has no negative effect on the logging since all log records are cached and automatically sent off once the log service is available). Use a daemon thread to avoid shutdown problems if this method still hangs in the login loop.
When the log service is obtained, the log queue used for remote logging will be flushed periodically to the log service unless an otherwise triggered flush has done this already. The default period is 10 seconds, but can be overridden in the CDB.
|
|
If not done already, sets up remote handlers for all loggers using a shared queue. Reimplemented in alma::acs::logging::RemoteLoggingTest::ClientLogManagerStandalone.
|
|
Takes the process name and overwrites previous names, and updates all Loggers which are waiting to get their overly simple name enriched. The new name will be the old name + @ + processName. The update mechanism ensures that the process name will eventually be set also on loggers which were created before the process name was known, e.g. component logger created before container logger. check if we still need the process name appended to the logger name, now that we have a separate field for it in AcsLogger.
|
|
Shuts down remote ACS logging. The loggers can still be used, but will only log locally.
|
|
Allows to suppress remote logging of Corba/ORB logger(s). Internally this suppression is handled using log level changes that cannot be undone by other log level changes. Generally remote logging remains enabled though, which makes this method quite different from suppressRemoteLogging()}. Application code such as components must not call this method!
|
|
Suppresses remote logging. If log messages destined for remote logging have not been sent to the central log service yet (e.g. because initRemoteLogging has not been called, or because of sending failures), these log messages will be lost for remote logging. Log messages produced after this call will not even be queued for remote logging. This method should only be called by special ALMA applications such as the Observation Preparation tool, which runs stand-alone, with all containers, managers, etc. in one JVM. In this case, no central logger is available, and all loggers which normally send their output to the central logger should be limited to local logging (stdout).
It is possible (probably not useful in real life) to re-enable remote logging later, by calling |
|
for testing |
|
The time in seconds between the periodic log queue flushings |
|
|
|
The log dispatcher object serves as a flag for whether remote logging has been activated via initRemoteLogging(ORB, Manager, int, boolean). |
|
We store all loggers in this map instead of giving them to LogManager which does not allow to remove loggers and would thus prevent component loggers from being garbage collected. |
|
The log queue can be null if remote logging has been suppressed. Otherwise it is non-null even if remote logging is not active, because it stores the records to be sent off later. |
|
|
|
The (CORBA-) name of the remote logging service to which logs will be sent |
|
Logger used by the classes in this logging package. TODO: allow container or client to replace this logger with their own logger, because these classes belong to their respective process. |
|
Parent logger of all remote loggers. Not really needed any more now that handlers are not shared. |
|
The process name gets used as a data field in the log record, and also gets appended to the name for the Corba logger, so that different ORB instances in the system can be distinguished. |
|
|
|
instance of a singleton |
|
The logging configurator shared by various classes of this package |
|
If true then the Corba (ORB) logger will not send logs to the Log service. |