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

alma.acs.logging.ClientLogManager Class Reference

Inheritance diagram for alma.acs.logging.ClientLogManager:
alma.acs.logging.config.LogConfigSubscriber

List of all members.

Classes

class  AcsLoggerInfo
interface  LogAlarmHandler
class  ThrottleCallback

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 enableLoggingAlarms (LogAlarmHandler logAlarmHandler)
void shutdown (boolean wait)
void flushAll ()

Static Public Member Functions

static synchronized
ClientLogManager 
getAcsLogManager ()

Protected Member Functions

 ClientLogManager ()
void prepareRemoteLogging ()
DispatchingLogQueue createDispatchingLogQueue ()
void disableRemoteLogging ()
StdOutConsoleHandler createStdOutConsoleHandlerWithFormatter (LogConfig logConfig, String loggerName, LogThrottle throttle)
AcsLogServiceOperations getLogService (Manager manager, int managerHandle) throws ComponentNotAlreadyActivatedEx, CannotGetComponentEx, NoPermissionEx, ComponentConfigurationNotFoundEx

Protected Attributes

volatile DispatchingLogQueue logQueue

Detailed Description

This class provides methods for getting the loggers for components and containers. Both the loggers and the handlers are organized in a hierarchical namespace so that children may inherit some properties from their parents in the namespace.

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.

Author:
hsommer

Member Enumeration Documentation

Enumerator:
ContainerLogger 
ComponentLogger 
OrbLogger 
OtherLogger 
UnknownLogger 

Constructor & Destructor Documentation


Member Function Documentation

DispatchingLogQueue alma.acs.logging.ClientLogManager.createDispatchingLogQueue (  )  [protected]

Factory method broken out from prepareRemoteLogging() to support tests.

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

StdOutConsoleHandler alma.acs.logging.ClientLogManager.createStdOutConsoleHandlerWithFormatter ( LogConfig  logConfig,
String  loggerName,
LogThrottle  throttle 
) [protected]

Factory method broken out to allow tests to easily use an instrumented variant.

void alma.acs.logging.ClientLogManager.disableRemoteLogging (  )  [protected]

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

Referenced by alma.acs.logging.ClientLogManager.shutdown(), and alma.acs.logging.ClientLogManager.suppressRemoteLogging().

void alma.acs.logging.ClientLogManager.enableLoggingAlarms ( LogAlarmHandler  logAlarmHandler  ) 
Since:
ACS 9.1
void alma.acs.logging.ClientLogManager.flushAll (  ) 

Flushes the remote log queue completely and returns only when it's done.

References alma.acs.logging.DispatchingLogQueue.flushAllAndWait(), and alma.acs.logging.ClientLogManager.logQueue.

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

static synchronized ClientLogManager alma.acs.logging.ClientLogManager.getAcsLogManager (  )  [static]

Singleton accessor.

TODO: rename, because now that we have class AcsLogManager, this method name is confusing.

Returns:
ClientLogManager

References alma.acs.logging.ClientLogManager.ClientLogManager().

LogConfig alma.acs.logging.ClientLogManager.getLogConfig (  ) 

Gets the LogConfig object that is shared between the ClientLogManager singleton and any other objects in the process (e.g. Java container or manager classes, Loggers, Handlers).

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

AcsLogger alma.acs.logging.ClientLogManager.getLoggerForApplication ( String  loggerName,
boolean  enableRemoteLogging 
)

Gets a logger for an application (which is not an ACS component itself), e.g. a GUI application using the ACS ComponentClient.

Parameters:
loggerName the logger name, should identify the application or the particular logger that gets requested.
enableRemoteLogging if true (generally recommended), the returned logger is set up to send the logs to the remote log service, as it always happens for container and component loggers. <emph>This will only work if initRemoteLogging(ORB, Manager, int, boolean) is also called, which happens automatically in ComponentClient. For a standalone application that is not ACS-aware (no manager known etc), remote logging is not available even with enableRemoteLogging == true.</emph>
Returns:
a configured Logger

References alma.acs.logging.AcsLogger.configureLevels(), alma.acs.logging.AcsLogger.createUnconfiguredLogger(), and alma.acs.logging.config.LogConfig.getNamedLoggerConfig().

AcsLogger alma.acs.logging.ClientLogManager.getLoggerForComponent ( String  componentName  ) 

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 alma.acs.container.ContainerServices should call this method.

Parameters:
componentName component name (sufficiently qualified to be unique in the system or log domain)
Returns:
AcsLogger
AcsLogger alma.acs.logging.ClientLogManager.getLoggerForContainer ( String  containerName  ) 

Gets a logger to be used by the Java container classes. The logger is connected to the central ACS logger.

AcsLogger alma.acs.logging.ClientLogManager.getLoggerForCorba ( String  corbaName,
boolean  autoConfigureContextName 
)

Gets a logger to be used by ORB and POA classes, or by hibernate. The logger is connected to the central ACS logger.

rename this method to accommodate non-corba frameworks into which we insert ACS loggers, such as hibernate, see org.slf4j.impl.ACSLoggerFactory.

For hibernate loggers, the logger automatically receives an initial custom log level configuration, to avoid jamming the log system with hibernate logs. The applied custom log level is the maximum of the default log level and WARNING. Note that the hibernate logger can still be set to a more verbose level by giving it a custom log config in the CDB, or dynamically using logLevelGUI etc.

Instead of this hard coded and probably confusing application of a custom log level, the CDB should offer a central configuration option for all jacorb, hibernate etc loggers, independently of the process (container or manager etc).

Parameters:
corbaName e.g. jacorb. rename it.
autoConfigureContextName if true, the context (e.g. container name) will be appended to this logger's name as soon as it is available, changing the logger name to something like jacorb.

References alma.acs.logging.AcsLogger.addIgnoreLogs(), alma.acs.logging.config.LogConfig.getDefaultMinLogLevel(), alma.acs.logging.config.LogConfig.getDefaultMinLogLevelLocal(), alma.acs.logging.config.LogConfig.hasCustomConfig(), alma.acs.logging.config.LogConfig.setAndLockMinLogLevel(), alma.acs.logging.config.LogConfig.setMinLogLevel(), alma.acs.logging.config.LogConfig.setMinLogLevelLocal(), and alma.acs.logging.ClientLogManager.suppressCorbaRemoteLogging().

AcsLogServiceOperations alma.acs.logging.ClientLogManager.getLogService ( Manager  manager,
int  managerHandle 
) throws ComponentNotAlreadyActivatedEx, CannotGetComponentEx, NoPermissionEx, ComponentConfigurationNotFoundEx [protected]

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.

Since ACS 8.0.1 we use an ACS-specific subtype of LogOperations to avoid the marshalling to Corba Any.

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

boolean alma.acs.logging.ClientLogManager.initRemoteLogging ( ORB  orb,
Manager  manager,
int  managerHandle,
boolean  retry 
)

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 retry is true. Total retries are limited to 5, to detect a permanent problem before the log queue overflows.

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.

Parameters:
orb the ORB used in this JVM
manager the ACS manager
managerHandle handle assigned by the ACS Manager for this client
retry if true, a failing connection to the log service will trigger up to 5 other attempts, every 10 seconds.
Returns:
true if remote logging was initialized successfully
See also:
shutdown(boolean)

References alma.acs.logging.DispatchingLogQueue.flushAllAndWait(), alma.acs.logging.ClientLogManager.getLogService(), alma.acs.logging.ClientLogManager.logQueue, alma.acs.logging.ClientLogManager.prepareRemoteLogging(), alma.acs.logging.DispatchingLogQueue.setPeriodicFlushing(), and alma.acs.logging.DispatchingLogQueue.setRemoteLogDispatcher().

void alma.acs.logging.ClientLogManager.shutdown ( boolean  wait  ) 

Shuts down remote ACS logging and nulls the singleton instance. The loggers can still be used, but will only log locally.

Parameters:
wait 

References alma.acs.logging.ClientLogManager.disableRemoteLogging(), alma.acs.logging.DispatchingLogQueue.flush(), alma.acs.logging.ClientLogManager.flushAll(), alma.acs.logging.ClientLogManager.logQueue, and alma.acs.logging.DispatchingLogQueue.shutDown().

void alma.acs.logging.ClientLogManager.suppressCorbaRemoteLogging (  ) 

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!

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

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

void alma.acs.logging.ClientLogManager.suppressRemoteLogging (  ) 

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

References alma.acs.logging.ClientLogManager.disableRemoteLogging(), and alma.acs.logging.ClientLogManager.logQueue.


Member Data Documentation


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