Platform SDK Java 8.5 API Reference

com.genesyslab.platform.apptemplate.lmslogger
Class LmsLoggerFactory

java.lang.Object
  extended by com.genesyslab.platform.apptemplate.lmslogger.LmsLoggerFactory
Direct Known Subclasses:
DirectLmsLoggerFactory, JulLmsLoggerFactory, LmsLoggerFactory.WrappedLoggerFactory, Log4j2LmsLoggerFactory, Log4jLmsLoggerFactory, SilentLmsLoggerFactory, SimpleLmsLoggerFactory, Slf4jLmsLoggerFactory

public abstract class LmsLoggerFactory
extends java.lang.Object

Abstract factory class for LMS event loggers.
It's the entry point of the LMS logging functionality.

Common usage scenario is simple:

 LmsLoggerFactory.createInstance(new LmsMessageConveyor());
 LmsEventLogger lmsLogger = LmsLoggerFactory.getLmsLogger(getClass());
 
If application has own LMS file declarations, it may use custom LmsEnum enumeration(s):
 LmsLoggerFactory.createInstance(
         new LmsMessageConveyor(CommonLmsEnum.class, MyAppLmsEnum.class));
 ...
 
Note: If application uses the Application Configuration Manager, there is no need to configure LmsLofferFactory - it will be done by the manager. It only needs to have properly constructed LmsMessageConveyor

Wrapping of LmsEventLogger's and LmsLoggerFactory allows applications to make LMS logging redirection/reconfiguration in a runtime.
So, it is possible to start application with LMS logging switched off, or with some "default" configuration, for example, logging to Slf4j, and later, when a new application configuration obtained, to change logging target to Log4j2.

 // Reconfigure LMS loggers to direct logs to Log4j2:
 LmsLoggerFactory.setLoggerFactoryImpl(Log.LOG_FACTORY_LOG4J2, lmsMessageConveyor);
 
Application Template AB contains several built-in implementations of LmsLoggerFactory.
Those ones are adapters for the following logging frameworks: Log4j2, Slf4j, Log4j, and java.util.logging.
There are also simple custom factories to write logs to stdout, and to switch LMS logging off.

See Also:
LmsMessageConveyor

Nested Class Summary
static class LmsLoggerFactory.AbstractFactoryBuilder<F extends LmsLoggerFactory,B extends LmsLoggerFactory.AbstractFactoryBuilder<F,B>>
           
protected static class LmsLoggerFactory.WrappedLogger
          The LmsEventLogger wrapper to be implicitly used by applications.
It makes possible automatic reconfiguration of LMS events logging without recreation of applications' loggers instances.
protected static class LmsLoggerFactory.WrappedLoggerFactory
          The LmsLoggerFactory wrapper to provide application with wrapped LmsEventLogger's.
 
Field Summary
static java.lang.String LMS_LOGGER_FACTORY_CLASS_PROP
           
 
Constructor Summary
protected LmsLoggerFactory(LmsMessageConveyor lmsc)
          Protected constructor of the abstract class.
 
Method Summary
static LmsLoggerFactory createInstance(LmsMessageConveyor lmsConveyor)
          Creates and initializes the application singleton instance of LmsLoggerFactory.
abstract  LmsEventLogger getLmsLogger(java.lang.Class<?> clazz)
          Gets an LmsEventLogger instance by class.
abstract  LmsEventLogger getLmsLogger(java.lang.String name)
          Gets an LmsEventLogger instance by name.
static LmsEventLogger getLogger(java.lang.Class<?> clazz)
          Gets an LmsEventLogger instance by class.
It uses statically initialized and wrapped logger factory instance.
So, this it may be used after initialization with createInstance(LmsMessageConveyor).
Its wrapping allows automatic reconfiguration of LmsEventLogger implementation without need to recreate LmsEventLogger's instances by user application.
static LmsEventLogger getLogger(java.lang.String name)
          Gets an LmsEventLogger instance by name.
It uses statically initialized and wrapped logger factory instance.
So, this it may be used after initialization with createInstance(LmsMessageConveyor).
Its wrapping allows automatic reconfiguration of LmsEventLogger implementation without need to recreate LmsEventLogger's instances by user application.
static LmsLoggerFactory getLoggerFactory()
          Returns reference to the static LmsLoggerFactory singleton instance.
 LmsMessageConveyor getMessageConveyor()
          Returns reference to the LmsMessageConveyor instance of this logger factory.
static LmsLoggerFactory setLoggerFactoryImpl(LmsLoggerFactory factory)
          Sets LMS logging system implementation.
static LmsLoggerFactory setLoggerFactoryImpl(java.lang.String factoryName, LmsMessageConveyor lmsConveyor)
          Sets LMS logging system implementation.
It may initialize LMS logging to work with one of PSDK built-in implementations, or user defined one, by its fully qualified class name or alias name.
Following alias names are supported: Log.LOG_FACTORY_CONSOLE ("console") - This implementation of LMS logging functionality prints LMS events to stdout; Log.LOG_FACTORY_LOG4J2 ("log4j2") - This factory is to send LMS events to Log4j v2.x logging framework; Log.LOG_FACTORY_SLF4J ("slf4j") - This factory is to send LMS events to Slf4j API; Log.LOG_FACTORY_LOG4J ("log4j") - This factory is to send LMS events to Log4j v1.x logging framework; Log.LOG_FACTORY_JUL ("jul") - This factory is to send LMS events to java.util.logging facade; Log.LOG_FACTORY_AUTO ("auto") - It tries to detect available logging framework for LMS events logging in the following order: Log4j2, Slf4j, Log4j; if none of these frameworks is available, java.util.logging will be used; Log.LOG_FACTORY_NONE ("none") - It is to do not log events from LMS events loggers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LMS_LOGGER_FACTORY_CLASS_PROP

public static final java.lang.String LMS_LOGGER_FACTORY_CLASS_PROP
See Also:
Constant Field Values
Constructor Detail

LmsLoggerFactory

protected LmsLoggerFactory(LmsMessageConveyor lmsc)
Protected constructor of the abstract class.

Parameters:
lmsc - the LMS events definitions conveyor.
Method Detail

getLoggerFactory

public static LmsLoggerFactory getLoggerFactory()
Returns reference to the static LmsLoggerFactory singleton instance.

Returns:
the LmsLoggerFactory reference, or null if it has not been initialized yet.
See Also:
createInstance(LmsMessageConveyor), setLoggerFactoryImpl(LmsLoggerFactory)

createInstance

public static LmsLoggerFactory createInstance(LmsMessageConveyor lmsConveyor)
Creates and initializes the application singleton instance of LmsLoggerFactory.

This is the recommended way for initialization of LMS events logging functionality.
It allows deployment time and runtime reconfiguration of LMS loggers.

To choose loggers factory implementation it looks to the following places:

  1. System property "com.genesyslab.platform.apptemplate.lmslogger.factory".
    If it contains FQCN of specific class extending LmsLoggerFactory, or alias name of built-in implementation, than the correspondent class constructor with LmsMessageConveyor parameter is used to initialize the static logger factory.
  2. Platform SDK customization option PsdkCustomization.PsdkOption.PsdkLoggerFactory (and its correspondent system property).
    If previously described system property is not specified, it checks this one.
    If the PSDK Commons Logging implementation is configured with this option using alias name of built-in implementation, this value is also used by this method to synchronize target logging framework.
  3. If these two options are not provided, "silent" loggers factory will be used. I.e. no logs will be generated by default.
    Note: it is still possible to enable it in a runtime with call like LmsLoggerFactory.setLoggerFactoryImpl(Log.LOG_FACTORY_LOG4J2, lmsMessageConveyor).

Parameters:
lmsConveyor - the LMS events definitions conveyor or null for the default LmsMessageConveyor.
Returns:
wrapped instance of LmsLoggerFactory.

getLogger

public static LmsEventLogger getLogger(java.lang.String name)
Gets an LmsEventLogger instance by name.
It uses statically initialized and wrapped logger factory instance.
So, this it may be used after initialization with createInstance(LmsMessageConveyor).
Its wrapping allows automatic reconfiguration of LmsEventLogger implementation without need to recreate LmsEventLogger's instances by user application.

Parameters:
name - the logger name.
Returns:
wrapped instance of named LmsEventLogger.
See Also:
createInstance(LmsMessageConveyor)

getLogger

public static LmsEventLogger getLogger(java.lang.Class<?> clazz)
Gets an LmsEventLogger instance by class.
It uses statically initialized and wrapped logger factory instance.
So, this it may be used after initialization with createInstance(LmsMessageConveyor).
Its wrapping allows automatic reconfiguration of LmsEventLogger implementation without need to recreate LmsEventLogger's instances by user application.

Parameters:
clazz - class to get the logger for.
Returns:
wrapped instance of LmsEventLogger named by the class.
See Also:
createInstance(LmsMessageConveyor)

setLoggerFactoryImpl

public static LmsLoggerFactory setLoggerFactoryImpl(LmsLoggerFactory factory)
Sets LMS logging system implementation.

Parameters:
factory - new factory that creates loggers.
Returns:
wrapped instance of LmsLoggerFactory.

setLoggerFactoryImpl

public static LmsLoggerFactory setLoggerFactoryImpl(java.lang.String factoryName,
                                                    LmsMessageConveyor lmsConveyor)
Sets LMS logging system implementation.
It may initialize LMS logging to work with one of PSDK built-in implementations, or user defined one, by its fully qualified class name or alias name.
Following alias names are supported:

Parameters:
factoryName - name of standard PSDK logger factory or class name of custom user implementation of it.
lmsConveyor - reference to new LmsMessageConveyor or null to reuse one from the current factory instance.
Returns:
wrapped instance of LmsLoggerFactory.
Throws:
java.lang.IllegalArgumentException - in case of wrong value of the given factory name.

getMessageConveyor

public LmsMessageConveyor getMessageConveyor()
Returns reference to the LmsMessageConveyor instance of this logger factory.

Returns:
the LMS Message Conveyor.

getLmsLogger

public abstract LmsEventLogger getLmsLogger(java.lang.String name)
Gets an LmsEventLogger instance by name.

Parameters:
name - the logger name.
Returns:
LmsEventLogger named logger instance.

getLmsLogger

public abstract LmsEventLogger getLmsLogger(java.lang.Class<?> clazz)
Gets an LmsEventLogger instance by class.

Parameters:
clazz - class to get the logger for.
Returns:
LmsEventLogger instance named by the class.

Platform SDK Java 8.5 API Reference

Send comments on this topicTechpubs.webadmin@genesys.com.
Document version: 8.5.302.00
Copyright © 2006–2017 Genesys Telecommunications Laboratories, Inc. All rights reserved.