Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

alma::acs::logging::ClientLogManager Class Reference

Inheritance diagram for alma::acs::logging::ClientLogManager:

Inheritance graph
[legend]
Collaboration diagram for alma::acs::logging::ClientLogManager:

Collaboration graph
[legend]
List of all members.

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, AcsLoggerInfologgers = 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

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

enum alma::acs::logging::ClientLogManager::LoggerOwnerType
 

Enumeration values:
ContainerLogger 
ComponentLogger 
OrbLogger 
OtherLogger 
UnknownLogger 


Constructor & Destructor Documentation

alma::acs::logging::ClientLogManager::ClientLogManager  )  [inline, protected]
 


Member Function Documentation

StdOutConsoleHandler alma::acs::logging::ClientLogManager::addLocalHandler AcsLogger  logger  )  [inline, private]
 

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 logger to be already registered in loggers}, but if it is, then the new StdOutConsoleHandler is set in the map's AcsLoggerInfo as well.

Parameters:
logger logger to be set up for local logging
Returns:
the local handler that was added to the logger.

AcsLoggingHandler alma::acs::logging::ClientLogManager::addRemoteHandler AcsLogger  logger  )  [inline, private]
 

Attaches a remote log handler to the given logger, if remote logging has not been suppressed.

Note that this method does not require logger to be already registered in loggers}, but if it is, then the new AcsLoggingHandler is set in the map's AcsLoggerInfo as well.

Parameters:
logger logger to be set up for remote logging
Returns:
the remote handler that was added to the logger.

void alma::acs::logging::ClientLogManager::configureLogging LogConfig  logConfig  )  [inline]
 

See also:
alma.acs.logging.config.LogConfigSubscriber::configureLogging(alma.acs.logging.LogConfig)

void alma::acs::logging::ClientLogManager::disableRemoteLogging  )  [inline, 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.

void alma::acs::logging::ClientLogManager::flushAll  )  [inline]
 

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

AcsLogger alma::acs::logging::ClientLogManager::getAcsLogger String  loggerName,
LoggerOwnerType  loggerOwnerType
[inline, private]
 

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 loggerName! The idea of this strategy is that uniqueness of component names will be enforced by the system, while a component may in sick cases have the name of a container or the orb logger.

Parameters:
loggerName The unique logger name
loggerOwnerType enum for the type of the logger owner. With ACS 7.0, this replaces the namespace strings previously prepended to the logger names.
Returns:
Exceptions:
IllegalArgumentException if loggerName is null or empty

synchronized ClientLogManager alma::acs::logging::ClientLogManager::getAcsLogManager  )  [inline, static]
 

Singleton accessor.

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

Returns:
ClientLogManager

LogConfig alma::acs::logging::ClientLogManager::getLogConfig  )  [inline]
 

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

AcsLogger alma::acs::logging::ClientLogManager::getLoggerForApplication String  loggerName,
boolean  enableRemoteLogging
[inline]
 

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

AcsLogger alma::acs::logging::ClientLogManager::getLoggerForComponent String  componentName  )  [inline]
 

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  )  [inline]
 

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
[inline]
 

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

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

LogOperations alma::acs::logging::ClientLogManager::getLogService Manager  manager,
int  managerHandle
throws ComponentNotAlreadyActivatedEx, CannotGetComponentEx, NoPermissionEx, ComponentConfigurationNotFoundEx [inline, 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.

Reimplemented in alma::acs::logging::RemoteLoggingTest::ClientLogManagerStandalone.

boolean alma::acs::logging::ClientLogManager::initRemoteLogging ORB  orb,
Manager  manager,
int  managerHandle,
boolean  retry
[inline]
 

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)

void alma::acs::logging::ClientLogManager::prepareRemoteLogging  )  [inline, protected]
 

If not done already, sets up remote handlers for all loggers using a shared queue.

Reimplemented in alma::acs::logging::RemoteLoggingTest::ClientLogManagerStandalone.

void alma::acs::logging::ClientLogManager::setProcessName String  processName  )  [inline, private]
 

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.

Parameters:
name 

void alma::acs::logging::ClientLogManager::shutdown boolean  wait  )  [inline]
 

Shuts down remote ACS logging. The loggers can still be used, but will only log locally.

Parameters:
wait 

void alma::acs::logging::ClientLogManager::suppressCorbaRemoteLogging  )  [inline]
 

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!

void alma::acs::logging::ClientLogManager::suppressRemoteLogging  )  [inline]
 

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.


Member Data Documentation

boolean alma::acs::logging::ClientLogManager::DEBUG = Boolean.getBoolean("alma.acs.logging.verbose") [private]
 

for testing

volatile int alma::acs::logging::ClientLogManager::flushPeriodSeconds [private]
 

The time in seconds between the periodic log queue flushings

boolean alma::acs::logging::ClientLogManager::LOG_BIN_TYPE = Boolean.getBoolean("ACS.loggingBin") [private]
 

RemoteLogDispatcher alma::acs::logging::ClientLogManager::logDispatcher [private]
 

The log dispatcher object serves as a flag for whether remote logging has been activated via initRemoteLogging(ORB, Manager, int, boolean).

final Map<String, AcsLoggerInfo> alma::acs::logging::ClientLogManager::loggers = new HashMap<String AcsLoggerInfo>() [private]
 

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.

volatile DispatchingLogQueue alma::acs::logging::ClientLogManager::logQueue [protected]
 

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.

final ReentrantLock alma::acs::logging::ClientLogManager::logQueueLock = new ReentrantLock() [private]
 

volatile String alma::acs::logging::ClientLogManager::logServiceName [private]
 

The (CORBA-) name of the remote logging service to which logs will be sent

final Logger alma::acs::logging::ClientLogManager::m_internalLogger [private]
 

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.

Logger alma::acs::logging::ClientLogManager::parentRemoteLogger [private]
 

Parent logger of all remote loggers. Not really needed any more now that handlers are not shared.

String alma::acs::logging::ClientLogManager::processName [private]
 

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.

final ReentrantLock alma::acs::logging::ClientLogManager::processNameLock = new ReentrantLock() [private]
 

volatile ClientLogManager alma::acs::logging::ClientLogManager::s_instance [static, private]
 

instance of a singleton

final LogConfig alma::acs::logging::ClientLogManager::sharedLogConfig [private]
 

The logging configurator shared by various classes of this package

volatile boolean alma::acs::logging::ClientLogManager::suppressCorbaRemoteLogging = false [private]
 

If true then the Corba (ORB) logger will not send logs to the Log service.


The documentation for this class was generated from the following file:
Generated on Thu Apr 30 02:53:39 2009 for ACS Java API by doxygen 1.3.8