soap tutorial

adriani.jws.template.util
Class ExternalLogger

java.lang.Object
  extended by adriani.jws.template.util.ExternalLogger
All Implemented Interfaces:
LoggerManager

public class ExternalLogger
extends java.lang.Object
implements LoggerManager

The class managing the logging mechanism when using the Log4j library. Notice that in the Log4j paradigm this class is not necessary, since any class should contain a class attribute like the following:

protected static Logger logger = Logger.getLogger(MyApp.class) ;

This project needs this class only to ensure compatibility with the logging system offered by the SystemLogger class, in this way it's possible to switch between the two logging system simply changing the logger.type property in the service configuration file.

See Also:
SystemLogger

Field Summary
protected  java.lang.String datePattern
          The rotation date pattern set for this logger.
protected static java.lang.String leadingName
          Beginning of each logging message printed on the STDOUT.
protected  java.lang.String loggerPath
          The absolute log path retrieved from the configuration file.
 
Constructor Summary
ExternalLogger()
           
 
Method Summary
 boolean close()
          NOT USED AT THE MOMENT (place holder).
 void createLogger(java.lang.String path, java.util.logging.Level level, boolean mode)
          NOT USED AT THE MOMENT (place holder).
 java.lang.String getParentDir(java.lang.Object logger)
          Return the parentDir path used as base directory to locate the log file.
protected  java.util.Properties getProperties(java.util.ResourceBundle resource)
          Convert ResourceBundle into a Properties object.
 RotateThread getRotateThread()
          Not used in current implementation, since roll over and rotation of the log file is performed automatically by the Log4j external module.
 java.lang.String getRotationTime(java.lang.Object logger)
          Return the rotation time set for this logger, already formatted and ready to print.
 void init(java.lang.String path, java.lang.String logLevel, int rotate, boolean mode)
          This method forces the Logger to load configuration from the log4j.properties file.
 void rotate()
          NOT USED AT THE MOMENT (place holder).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

loggerPath

protected java.lang.String loggerPath
The absolute log path retrieved from the configuration file.


datePattern

protected java.lang.String datePattern
The rotation date pattern set for this logger.


leadingName

protected static java.lang.String leadingName
Beginning of each logging message printed on the STDOUT.

Constructor Detail

ExternalLogger

public ExternalLogger()
Method Detail

init

public void init(java.lang.String path,
                 java.lang.String logLevel,
                 int rotate,
                 boolean mode)
This method forces the Logger to load configuration from the log4j.properties file.
Such file is searched first in the classpath (e.g. in the Axis2/WEB-INF directory), if not found is searched within the AAR file (embedded configuration). If the properties file is still not found, this method set the basic configuration (Log4j default) for all the Log4j logger objects.

Specified by:
init in interface LoggerManager
Parameters:
path - not used (required only to implement the LoggerManager interface)
logLevel - not used (required only to implement the LoggerManager interface)
rotate - not used (required only to implement the LoggerManager interface)
mode - not used (required only to implement the LoggerManager interface)

createLogger

public void createLogger(java.lang.String path,
                         java.util.logging.Level level,
                         boolean mode)
NOT USED AT THE MOMENT (place holder).

Specified by:
createLogger in interface LoggerManager
Parameters:
path - the path reference for the log file
level - the logging minimal level as a Logger.Level value (INFO, WARNING or SEVERE)
mode - if true creates the standard log file, if false creates the benchmark analysis file
See Also:
SystemLogger.getLogFile(String optionalPath, boolean mode)

rotate

public void rotate()
NOT USED AT THE MOMENT (place holder).

Specified by:
rotate in interface LoggerManager
See Also:
RotateThread

close

public boolean close()
NOT USED AT THE MOMENT (place holder).

Specified by:
close in interface LoggerManager

getParentDir

public java.lang.String getParentDir(java.lang.Object logger)
Return the parentDir path used as base directory to locate the log file.
Usually this parameter is retrieved from the RootLogger reference, because the method root.getAllAppenders() returns only the EXPLICIT appenders, and not the appenders obtained from a parent logger. In this case we do not use the RootLogger, because we assume the Log4j configuration file is something like:

 log4j.additivity.template         = false
 log4j.additivity.template.db      = false
 log4j.additivity.template.service = false
 log4j.logger.template             = INFO, stdout, myfile
 log4j.logger.template.db          = INFO, stdout, myfile
 log4j.logger.template.service     = INFO, stdout, myfile
 


Hence each logger object has his own explicit reference to the output file (myfile), for this reason we can use directly smartLogger.getAllAppenders().

Specified by:
getParentDir in interface LoggerManager
Parameters:
logger - a valid org.apache.log4j.Logger instance
Returns:
the current parent directory for logging on the file system

getRotateThread

public RotateThread getRotateThread()
Not used in current implementation, since roll over and rotation of the log file is performed automatically by the Log4j external module.

Specified by:
getRotateThread in interface LoggerManager
Returns:
a null reference, since logger rotation is performed by Log4j

getRotationTime

public java.lang.String getRotationTime(java.lang.Object logger)
Return the rotation time set for this logger, already formatted and ready to print.
Usually this parameter is retrieved from the RootLogger reference, because the method root.getAllAppenders() returns only the EXPLICIT appenders, and not the appenders obtained from a parent logger. In this case we do not use the RootLogger, because we assume the Log4j configuration file is something like:

 log4j.additivity.template         = false
 log4j.additivity.template.dba     = false
 log4j.additivity.template.logic   = false
 log4j.logger.template             = INFO, stdout, myfile
 log4j.logger.template.dba         = INFO, stdout, myfile
 log4j.logger.template.logic       = INFO, stdout, myfile
 

Hence each logger object has his own explicit reference to the output file (myfile), for this reason we can use directly: smartLogger.getAllAppenders().

Specified by:
getRotationTime in interface LoggerManager
Parameters:
logger - a valid org.apache.log4j.Logger instance
Returns:
a string describing the rotation time set for this logger

getProperties

protected java.util.Properties getProperties(java.util.ResourceBundle resource)
Convert ResourceBundle into a Properties object.
This method is necessary because Axis2 uses the Log4j mechanism to log events, as defined in the log4j.properties file in the axis2\WEB-INF\classes directory. This means that all the Logger objects instantiated by the Axis2 classloader will use the configuration specified by the log4j.properties mentioned above. Hence, to avoid setting the logging configuration in that file, we load our Log4j settings as a ResourceBundle object and then we convert it into a Properties object.

Parameters:
resource - the resource bundle to convert
Returns:
the properties version of the resource bundle

Build 18/09/2012

Morpheus Quality Technologies - Making the Zion software
Copyright © 2009-2013 Morpheus Quality Technologies. All Rights Reserved