|
soap tutorial | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectadriani.jws.template.util.WSLogger
public class WSLogger
This class has two different purposes: static factory and logger instance.
All the static
attributes and methods written here are used to implement a
factory which creates WSLogger
single objects, used by all the other classes
to write message on the logging system. This section contains:
loggerManager
object, benchLogger
object,
table
hashtable, logPath
, rotation time, initialized flag.initialize()
method (to be run once) and the getLogger()
method, the last representing the actual Factory for creating loggers.WSLogger
instance, which is a wrapper
for the actual logger being used (JAVA or LOG4J). The logger instance offers:
Field Summary | |
---|---|
protected static LoggerManager |
benchLogger
Reference to the static benchLogger created at the first service invocation. |
protected java.util.logging.Logger |
javaLogger
Instance reference to the logger written using the POJO approach. |
protected static java.lang.String |
leadingName
Beginning of each logging message produced by this class. |
protected static LoggerManager |
loggerManager
Reference to the static loggerManager created at the first service invocation. |
protected static java.lang.String |
logPath
The logger path loaded from the configuration file for the current runtime environment. |
protected static WSLogger |
myLogger
The logger instance to be used for this class (static). |
protected static boolean |
ready
The boolean flag depicting if this class has already been initialized. |
protected static int |
rotate
The logger rotation time suggested loaded from the configuration file. |
protected org.apache.log4j.Logger |
smartLogger
Instance reference to the logger object relying on the Log4j mechanism. |
protected static boolean |
verbose
The boolean flag selecting the level on details message on STDOUT. |
Constructor Summary | |
---|---|
WSLogger(java.lang.String name)
The input name parameter is used only if the logging mechanism relies on the LOG4J
library. |
Method Summary | |
---|---|
static void |
closeBenchmark()
Closes the Benchmark logger |
void |
finalize()
Method useful for debug and testing, the verify the scope of the various logger instances. |
void |
flushLogger(java.util.logging.Logger logger)
Flush the Handler bound to the given Logger . |
static LoggerManager |
getBenchmarkLogger()
Return current implementation of the LoggerManager object, which is responsible for
creating and initializing the benchmark optional feature. |
static WSLogger |
getLogger(java.lang.Class caller)
The main static factory to be used by all other classes to ask and obtain a WSLogger
instance. |
static LoggerManager |
getLoggerManager()
Return current implementation of the LoggerManager object, which is responsible for
creating and initializing the log mechanism. |
java.lang.String |
getParentDir()
Return the parentDir path used as base directory to locate the log file. |
java.lang.String |
getRotationTime()
Return the rotation time set for this logger, already formatted and ready to print. |
static void |
initBenchmark()
Initializes the Benchmark logger, allowing to measure execution time of each single SQL statement. |
static void |
initialize()
Loads the logging parameters from the configuration.properties file, then creates the
required logger object, i.e. one subclass of the LoggerManager interface:If logger.type = LOG4J the logger will be a ExternalLogger instance. |
boolean |
isInfoEnabled()
Improves performances by avoiding to evaluate the concatened string message when the log call will not be executed (because not enabled for logger current level). |
static boolean |
isReady()
Factory accessor method. |
void |
logInfo(java.lang.String msg)
Log an INFO message on the default Logger and flush the relative Handler. |
void |
logSevere(java.lang.String msg)
Log a SEVERE message on the default Logger and flush the relative Handler. |
void |
logWarning(java.lang.String msg)
Log a WARNING message on the default Logger and flush the relative Handler. |
static java.lang.String |
printObject(java.lang.Object object)
Print the serialize reference number of the input object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static LoggerManager loggerManager
loggerManager
created at the first service invocation.
This object MUST BE static to ensure that all the subclasses of the GeneralService
class
do refer to the same loggerManager
object. Depending by the service configuration, the
loggerManager
can be a SystemLogger
(pure Java logger) or an
ExternalLogger
(Log4j logger).
protected static LoggerManager benchLogger
benchLogger
created at the first service invocation.
This object MUST BE static for the same reason of the loggerManager
object.benchLogger
logs on file detailed information about the single SQL queries, this
is different from the serviceAnalyzer
object, which collects global and statistical data.
SystemLogger
class.
protected static java.lang.String logPath
protected static int rotate
protected static boolean ready
protected static boolean verbose
Settings.VERBOSE
flag because we want to keep separated
the verbosity of the business logic from the verbosity of the logger system itself.
protected org.apache.log4j.Logger smartLogger
protected java.util.logging.Logger javaLogger
protected static java.lang.String leadingName
protected static WSLogger myLogger
Constructor Detail |
---|
public WSLogger(java.lang.String name)
name
parameter is used only if the logging mechanism relies on the LOG4J
library. Otherwise, if the JAVA logging system is used, all the logger instances will share
the same logic name (defined by the Settings.LOGGER
field).
name
- the logic name to be used for the LOG4J logger objectSettings
Method Detail |
---|
public void finalize()
finalize
in class java.lang.Object
public static void initialize()
configuration.properties
file, then creates the
required logger object, i.e. one subclass of the LoggerManager
interface:logger.type = LOG4J
the logger will be a ExternalLogger
instance.logger.type = JAVA
the logger will be a SystemLogger
instance.
public static WSLogger getLogger(java.lang.Class caller)
WSLogger
instance. Remember that a WSLogger
instance MUST NOT be used to invoke the
initialize()
and getLogger()
methods.WSLogger
instance MUST BE used only for actual logging, calling one
of the standard logging interface: logInfo()
, logWarning()
,
logSevere()
and isInfoEnabled()
.
caller
- the class reference of the caller, e.g. GeneralService.class
public static boolean isReady()
public static LoggerManager getLoggerManager()
LoggerManager
object, which is responsible for
creating and initializing the log mechanism.
LoggerManager
objectpublic static LoggerManager getBenchmarkLogger()
LoggerManager
object, which is responsible for
creating and initializing the benchmark optional feature.
LoggerManager
objectpublic java.lang.String getParentDir()
parentDir
path used as base directory to locate the log file.
public java.lang.String getRotationTime()
public static void initBenchmark()
initialize()
: we moved it
out from that method in order to restore the possibility to activate the benchmark logger at run-time
(this feature was broken after the 2012-2013 refactory).
public static void closeBenchmark()
public void logInfo(java.lang.String msg)
Logger
and flush the relative Handler.
msg
- the text message to be logged on the current loggerpublic void logWarning(java.lang.String msg)
Logger
and flush the relative Handler.
msg
- the text message to be logged on the current loggerpublic void logSevere(java.lang.String msg)
Logger
and flush the relative Handler.
msg
- the text message to be logged on the current loggerpublic void flushLogger(java.util.logging.Logger logger)
Logger
. Used only when the SystemLogger
class is used to log messages instead of the Log4j mechanism.
logger
- a reference to the logger object to be flushedpublic boolean isInfoEnabled()
false
if no logger is found.
true
if the INFO log level is enabled on the current Loggerpublic static java.lang.String printObject(java.lang.Object object)
object
- a generic Java object, e.g. MyObject@1bd4722
|
Build 18/09/2012 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |