Class Log4JWrapper
- java.lang.Object
-
- de.hybris.platform.sap.core.bol.logging.Log4JWrapper
-
public class Log4JWrapper extends java.lang.ObjectLog4JWrapper.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedLog4JWrapper(java.lang.String name)Constructor for creating a logging object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddAppender(org.apache.log4j.Appender appender)Adds an additional appender to logging object.voiddebug(java.lang.Object message)Logs a message object with theDEBUGpriority.voiddebug(java.lang.Object message, java.lang.Throwable t)Log a message object with theDEBUGpriority including the stack trace of theThrowabletpassed as parameter.voiddebug(java.lang.String message, java.lang.Object[] args)Trace a message object with theDEBUGpriority, by merging the given args with the message string.voiddebugWithArgs(java.lang.String message, java.lang.Object arg0)Trace a message object with theDEBUGpriority, by merging the given argument with the message string.voiddebugWithArgs(java.lang.String message, java.lang.Object arg0, java.lang.Object arg1)Trace a message object with theDEBUGpriority, by merging the given arguments with the message string.voiddebugWithArgs(java.lang.String message, java.lang.Object arg0, java.lang.Object arg1, java.lang.Object arg2)Trace a message object with theDEBUGpriority, by merging the given arguments with the message string.voiddebugWithArgs(java.lang.String message, java.lang.Object arg0, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3)Trace a message object with theDEBUGpriority, by merging the given arguments with the message string.voidentering(java.lang.String method)Traces message of severity Severity.DEBUG and appends a string denoting the name of the entered method.voidexiting()Traces message of severity Severity.DEBUG which indicates that execution is about to leave this method location.static Log4JWrappergetInstance(java.lang.String name)The method to retrieve the logging object.org.apache.log4j.LoggergetLogger()This methods returns the instance of the logger.booleanisDebugEnabled()Check whether this location is enabled for theDEBUGpriority.booleanisInfoEnabled()Check whether this location is enabled for the info priority.booleanisWarningEnabled()Check whether this location is enabled for the warning priority.voidlog(int severity, LogCategory category, java.lang.String message)Generates a log message for the given category.voidlog(int severity, LogCategory category, java.lang.String message, java.lang.Object[] args)Generates a log a message for the given severity and category by merging the given args with the message string.voidsetLevel(org.apache.log4j.Level level)Sets the log level.voidthrowing(java.lang.Throwable t)Should be used when an exception is thrown.voidtrace(int severity, java.lang.String message)Generates a trace message for the given severity.voidtrace(int severity, java.lang.String message, java.lang.Object[] args)Generates a trace message for the given severity by merging the given args with the message string.voidtraceThrowable(int severity, java.lang.String message, java.lang.Throwable exc)Generates a trace message for the given severity and exception.voidtraceThrowable(int severity, java.lang.Throwable exc, java.lang.String message, java.lang.Object[] args)Generates a trace message for the given severity and exception by merging the given args with the message string.
-
-
-
Method Detail
-
addAppender
protected void addAppender(org.apache.log4j.Appender appender)
Adds an additional appender to logging object.- Parameters:
appender- logging appender
-
getInstance
public static Log4JWrapper getInstance(java.lang.String name)
The method to retrieve the logging object. The name should contain the package name and class name.It will be ensured that only one instance is created
- Parameters:
name- - the name of the current logger.- Returns:
- the logger instance
-
log
public void log(int severity, LogCategory category, java.lang.String message)Generates a log message for the given category.- Parameters:
severity- the severity of the messagecategory- the log categorymessage- the message
-
log
public void log(int severity, LogCategory category, java.lang.String message, java.lang.Object[] args)Generates a log a message for the given severity and category by merging the given args with the message string. Placeholders for the arguments in the message string must look like {i} (e.g. {0}) where i is the index in the args array.- Parameters:
severity- the message severitycategory- the log categorymessage- the messageargs- the arguments of the message
-
trace
public void trace(int severity, java.lang.String message)Generates a trace message for the given severity.- Parameters:
severity- the message severitymessage- the message
-
trace
public void trace(int severity, java.lang.String message, java.lang.Object[] args)Generates a trace message for the given severity by merging the given args with the message string. Placeholders for the arguments in the message string must look like {i} (e.g. {0}) where i is the index in the args array.- Parameters:
severity- the message severitymessage- the messageargs- the arguments of the message
-
traceThrowable
public void traceThrowable(int severity, java.lang.String message, java.lang.Throwable exc)Generates a trace message for the given severity and exception.- Parameters:
severity- the message severitymessage- the messageexc- the exception
-
traceThrowable
public void traceThrowable(int severity, java.lang.Throwable exc, java.lang.String message, java.lang.Object[] args)Generates a trace message for the given severity and exception by merging the given args with the message string. Placeholders for the arguments in the message string must look like {i} (e.g. {0}) where i is the index in the args array.- Parameters:
severity- the message severityexc- the exceptionmessage- the messageargs- the arguments of the message
-
throwing
public void throwing(java.lang.Throwable t)
Should be used when an exception is thrown. The exception is written using its method toString with severity Severity.ERROR.- Parameters:
t- an occurring exception
-
entering
public void entering(java.lang.String method)
Traces message of severity Severity.DEBUG and appends a string denoting the name of the entered method. This method must be balanced with a call to exiting when leaving the traced method, for example exiting().- Parameters:
method- name of sublocation
-
exiting
public void exiting()
Traces message of severity Severity.DEBUG which indicates that execution is about to leave this method location. This method is to be balanced with a call to the method entering().
-
debug
public void debug(java.lang.Object message)
Logs a message object with theDEBUGpriority.- Parameters:
message- the message object to log using plain English.
-
debug
public void debug(java.lang.String message, java.lang.Object[] args)Trace a message object with theDEBUGpriority, by merging the given args with the message string. Placeholders for the arguments in the message string must look like {i} (e.g. {0}) where i is the index in the args array.- Parameters:
message- the message object to log using plain english.args- the Objects to merge with the given message.
-
debugWithArgs
public void debugWithArgs(java.lang.String message, java.lang.Object arg0)Trace a message object with theDEBUGpriority, by merging the given argument with the message string. Placeholder for the argument in the message string must be {0}. This method does not require to be surrounded with an if statement to check if debug is enabled, to inhibit unnecessary memory consumption.- Parameters:
message- the message object to log using plain English.arg0- the argument Object to merge with the given message for Placeholder {0}.
-
debugWithArgs
public void debugWithArgs(java.lang.String message, java.lang.Object arg0, java.lang.Object arg1)Trace a message object with theDEBUGpriority, by merging the given arguments with the message string. Placeholder for the argument in the message string must be {0} and {1}. This method does not require to be surrounded with an if statement to check if debug is enabled, to inhibit unnecessary memory consumption.- Parameters:
message- the message object to log using plain English.arg0- the argument Object to merge with the given message for Placeholder {0}.arg1- the argument Object to merge with the given message for Placeholder {1}.
-
debugWithArgs
public void debugWithArgs(java.lang.String message, java.lang.Object arg0, java.lang.Object arg1, java.lang.Object arg2)Trace a message object with theDEBUGpriority, by merging the given arguments with the message string. Placeholder for the argument in the message string must be {0}, {1} and {2}. This method does not require to be surrounded with an if statement to check if debug is enabled, to inhibit unnecessary memory consumption.- Parameters:
message- the message object to log using plain English.arg0- the argument Object to merge with the given message for Placeholder {0}.arg1- the argument Object to merge with the given message for Placeholder {1}.arg2- the argument Object to merge with the given message for Placeholder {2}.
-
debugWithArgs
public void debugWithArgs(java.lang.String message, java.lang.Object arg0, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3)Trace a message object with theDEBUGpriority, by merging the given arguments with the message string. Placeholder for the argument in the message string must be {0}, {1}, {2} and {3}. This method does not require to be surrounded with an if statement to check if debug is enabled, to inhibit unnecessary memory consumption.- Parameters:
message- the message object to log using plain English.arg0- the argument Object to merge with the given message for Placeholder {0}.arg1- the argument Object to merge with the given message for Placeholder {1}.arg2- the argument Object to merge with the given message for Placeholder {2}.arg3- the argument Object to merge with the given message for Placeholder {3}.
-
debug
public void debug(java.lang.Object message, java.lang.Throwable t)Log a message object with theDEBUGpriority including the stack trace of theThrowabletpassed as parameter.See
debug(Object)form for more detailed information.- Parameters:
message- the message object to log.t- the exception to log, including its stack trace.
-
isDebugEnabled
public boolean isDebugEnabled()
Check whether this location is enabled for theDEBUGpriority.This function is intended to lessen the computational cost of disabled log debug statements.
For some
catlocation object, when you write,cat.debug("This is entry number: " + i);You incur the cost constructing the message, concatenation in this case, regardless of whether the message is logged or not.
If you are worried about speed, then you should write
if (cat.isDebugEnabled()) { cat.debug("This is entry number: " + i); }This way you will not incur the cost of parameter construction if debugging is disabled for
cat. On the other hand, if thecatis debug enabled, you will incur the cost of evaluating whether the location is debug enabled twice. Once inisDebugEnabledand once in thedebug. This is an insignificant overhead since evaluating a location takes about 1% of the time it takes to actually log.- Returns:
- boolean -
trueif this location is debug enabled,falseotherwise.
-
isInfoEnabled
public boolean isInfoEnabled()
Check whether this location is enabled for the info priority. See alsoisDebugEnabled().- Returns:
- boolean -
trueif this location is enabled for priority info,falseotherwise.
-
isWarningEnabled
public boolean isWarningEnabled()
Check whether this location is enabled for the warning priority. See alsoisDebugEnabled().- Returns:
- boolean -
trueif this location is enabled for priority warning,falseotherwise.
-
getLogger
public org.apache.log4j.Logger getLogger()
This methods returns the instance of the logger.- Returns:
- the logger
-
setLevel
public void setLevel(org.apache.log4j.Level level)
Sets the log level.- Parameters:
level- the log level
-
-