org.jmonks.batch.framework
Class LoggingManager

java.lang.Object
  extended byorg.jmonks.batch.framework.LoggingManager

public class LoggingManager
extends java.lang.Object

Logging Manager provides the logging services to the framework. It defines the default logging mechanism at the framework level which works for all the jobs and provide the facility to use their own logging mechanism.

The default logging mechanism defined at the framework will work like this. It reads the directory to create the log files from the framework logging configuration <logging-config> and creates a directory with the "job-name" and create the log files for each run. So, the format will be

<directory-defined-in-config>/job-name/jobname_with_timestamp.log

If job developer would like to override this logging mechanism, they can define their logging configuration in the element <job-logging-config> in batch job configuration file or defining entries in job_logging_config table.

Since:
1.0
Version:
1.0
Author:
Suresh Pragada

Field Summary
static java.lang.String DEFAULT_MESSAGE_PATTERN
          Standard pattern expression used for all the log files.
static java.lang.String FRAMEWORK_LOGGING_FILE
          Framework configuration file which is batch_framework.log.
 
Method Summary
static boolean changeLogLevel(java.lang.String loggerName, org.apache.log4j.Level newLogLevel)
          Changes the log level for the requested logger name with the given log level.
static org.apache.log4j.Level getLogLevel(java.lang.String loggerName)
          Gets the log level of the given logger name.
static void initializeFrameworkLogging(FrameworkConfig.FrameworkLoggingConfig frameworkLoggingConfig, Main loggingInitalizer)
          Initializes the logging of the framework in the directory defined in framework configuration.
static void initializeJobLogging(java.lang.String jobName, FrameworkConfig.FrameworkLoggingConfig frameworkLoggingConfig, JobLoggingConfig jobLoggingConfig, Main loggingInitalizer)
           This method accepts all the information available from framwork logging configuration and job logging configuration and loads the required loggers appropriately.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FRAMEWORK_LOGGING_FILE

public static final java.lang.String FRAMEWORK_LOGGING_FILE
Framework configuration file which is batch_framework.log.

See Also:
Constant Field Values

DEFAULT_MESSAGE_PATTERN

public static final java.lang.String DEFAULT_MESSAGE_PATTERN
Standard pattern expression used for all the log files.

See Also:
Constant Field Values
Method Detail

initializeJobLogging

public static void initializeJobLogging(java.lang.String jobName,
                                        FrameworkConfig.FrameworkLoggingConfig frameworkLoggingConfig,
                                        JobLoggingConfig jobLoggingConfig,
                                        Main loggingInitalizer)

This method accepts all the information available from framwork logging configuration and job logging configuration and loads the required loggers appropriately. This does the follwing steps.

Parameters:
jobName - Name of the job.
frameworkLoggingConfig - Logging configuration defined at the framework.
loggingInitalizer - Main class instance which is authorized to initailze the job logging.
Throws:
java.lang.SecurityException - If any class other than Main(framework) tried to initialize the job logging.
ConfigurationException - If logging file cannot be created at the configured directory.


initializeFrameworkLogging

public static void initializeFrameworkLogging(FrameworkConfig.FrameworkLoggingConfig frameworkLoggingConfig,
                                              Main loggingInitalizer)
Initializes the logging of the framework in the directory defined in framework configuration. After initialized the job logging framework logging will be send to the job and framwork log files.

Parameters:
frameworkLoggingConfig - Framework logging configuration object.
loggingInitalizer - Main class instance which is authorized to initailze the logging.
Throws:
java.lang.SecurityException - If any class other than Main(framework) tried to initialize the framework logging.
ConfigurationException - If logging directory cannot be created.

getLogLevel

public static org.apache.log4j.Level getLogLevel(java.lang.String loggerName)
Gets the log level of the given logger name.

Parameters:
loggerName - Name of the logger wants to find the log level.
Returns:
Returns the log level, null, if the given logger could not be found.

changeLogLevel

public static boolean changeLogLevel(java.lang.String loggerName,
                                     org.apache.log4j.Level newLogLevel)
Changes the log level for the requested logger name with the given log level.

Parameters:
loggerName - Logger name needs to be modified.
newLogLevel - new logging level.
Returns:
Returns true, if log level could be changed, false, otherwise.