Class NOPLogger
- All Implemented Interfaces:
AppenderAttachable
- Since:
- 1.2.15
-
Field Summary
Fields inherited from class org.apache.log4j.Category
additive, level, name, parent, repository, resourceBundle -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAppender(Appender newAppender) AddnewAppenderto the list of appenders of this Category instance.voidvoidcallAppenders(LoggingEvent event) Call the appenders in the hierrachy starting atthis.voidLog a message object with theDEBUGlevel.voidLog a message object with theDEBUGlevel including the stack trace of theThrowabletpassed as parameter.voidLog a message object with theERRORLevel.voidLog a message object with theERRORlevel including the stack trace of theThrowabletpassed as parameter.voidLog a message object with theFATALLevel.voidLog a message object with theFATALlevel including the stack trace of theThrowabletpassed as parameter.Get the appenders contained in this category as anEnumeration.getAppender(String name) Look for the appender named asname.Starting from this category, search the category hierarchy for a non-null level and return it.Return the inheritedResourceBundlefor this category.voidLog a message object with theINFOLevel.voidLog a message object with theINFOlevel including the stack trace of theThrowabletpassed as parameter.booleanisAttached(Appender appender) Is the appender passed as parameter attached to this category?booleanCheck whether this category is enabled for theDEBUGLevel.booleanisEnabledFor(Priority level) Check whether this category is enabled for a givenLevelpassed as parameter.booleanCheck whether this category is enabled for the info Level.booleanCheck whether this category is enabled for the TRACE Level.voidLog a localized and parameterized message.voidLog a localized message.voidThis is the most generic printing method.voidThis generic form is intended to be used by wrappers.voidThis generic form is intended to be used by wrappers.voidRemove all previously added appenders from this Category instance.voidremoveAppender(String name) Remove the appender with the name passed as parameter form the list of appenders.voidremoveAppender(Appender appender) Remove the appender passed as parameter form the list of appenders.voidSet the level of this Category.voidsetPriority(Priority priority) Set the level of this Category.voidsetResourceBundle(ResourceBundle bundle) Set the resource bundle to be used with localized logging methodsCategory.l7dlog(Priority, String, Throwable)andCategory.l7dlog(Priority, String, Object[], Throwable).voidLog a message object with theTRACElevel.voidLog a message object with theTRACElevel including the stack trace of theThrowabletpassed as parameter.voidLog a message object with theWARNLevel.voidMethods inherited from class org.apache.log4j.Logger
getLogger, getLogger, getLogger, getRootLoggerMethods inherited from class org.apache.log4j.Category
exists, forcedLog, getAdditivity, getCurrentCategories, getDefaultHierarchy, getHierarchy, getInstance, getInstance, getLevel, getLoggerRepository, getName, getParent, getPriority, getResourceBundleString, getRoot, setAdditivity, shutdown
-
Constructor Details
-
NOPLogger
Create instance of Logger.- Parameters:
repo- repository, may not be null.name- name, may not be null, use "root" for root logger.
-
-
Method Details
-
addAppender
AddnewAppenderto the list of appenders of this Category instance.If
newAppenderis already in the list of appenders, then it won't be added again.- Specified by:
addAppenderin interfaceAppenderAttachable- Overrides:
addAppenderin classCategory
-
assertLog
Ifassertionparameter isfalse, then logsmsgas anerrorstatement.The
assertmethod has been renamed toassertLogbecauseassertis a language reserved word in JDK 1.4. -
callAppenders
Call the appenders in the hierrachy starting atthis. If no appenders could be found, emit a warning.This method calls all the appenders inherited from the hierarchy circumventing any evaluation of whether to log or not to log the particular log request.
- Overrides:
callAppendersin classCategory- Parameters:
event- the event to log.
-
debug
Log a message object with theDEBUGlevel.This method first checks if this category is
DEBUGenabled by comparing the level of this category with theDEBUGlevel. If this category isDEBUGenabled, then it converts the message object (passed as parameter) to a string by invoking the appropriateObjectRenderer. It then proceeds to call all the registered appenders in this category and also higher in the hierarchy depending on the value of the additivity flag.WARNING Note that passing a
Throwableto this method will print the name of theThrowablebut no stack trace. To print a stack trace use theCategory.debug(Object, Throwable)form instead. -
debug
Log a message object with theDEBUGlevel including the stack trace of theThrowabletpassed as parameter.See
Category.debug(Object)form for more detailed information. -
error
Log a message object with theERRORLevel.This method first checks if this category is
ERRORenabled by comparing the level of this category withERRORLevel. If this category isERRORenabled, then it converts the message object passed as parameter to a string by invoking the appropriateObjectRenderer. It proceeds to call all the registered appenders in this category and also higher in the hierarchy depending on the value of the additivity flag.WARNING Note that passing a
Throwableto this method will print the name of theThrowablebut no stack trace. To print a stack trace use theCategory.error(Object, Throwable)form instead. -
error
Log a message object with theERRORlevel including the stack trace of theThrowabletpassed as parameter.See
Category.error(Object)form for more detailed information. -
fatal
Log a message object with theFATALLevel.This method first checks if this category is
FATALenabled by comparing the level of this category withFATALLevel. If the category isFATALenabled, then it converts the message object passed as parameter to a string by invoking the appropriateObjectRenderer. It proceeds to call all the registered appenders in this category and also higher in the hierarchy depending on the value of the additivity flag.WARNING Note that passing a
Throwableto this method will print the name of the Throwable but no stack trace. To print a stack trace use theCategory.fatal(Object, Throwable)form instead. -
fatal
Log a message object with theFATALlevel including the stack trace of theThrowabletpassed as parameter.See
Category.fatal(Object)for more detailed information. -
getAllAppenders
Get the appenders contained in this category as anEnumeration. If no appenders can be found, then aNullEnumerationis returned.- Specified by:
getAllAppendersin interfaceAppenderAttachable- Overrides:
getAllAppendersin classCategory- Returns:
- Enumeration An enumeration of the appenders in this category.
-
getAppender
Look for the appender named asname.Return the appender with that name if in the list. Return
nullotherwise.- Specified by:
getAppenderin interfaceAppenderAttachable- Overrides:
getAppenderin classCategory
-
getEffectiveLevel
Starting from this category, search the category hierarchy for a non-null level and return it. Otherwise, return the level of the root category.The Category class is designed so that this method executes as quickly as possible.
- Overrides:
getEffectiveLevelin classCategory
-
getChainedPriority
- Overrides:
getChainedPriorityin classCategory
-
getResourceBundle
Return the inheritedResourceBundlefor this category.This method walks the hierarchy to find the appropriate resource bundle. It will return the resource bundle attached to the closest ancestor of this category, much like the way priorities are searched. In case there is no bundle in the hierarchy then
nullis returned.- Overrides:
getResourceBundlein classCategory
-
info
Log a message object with theINFOLevel.This method first checks if this category is
INFOenabled by comparing the level of this category withINFOLevel. If the category isINFOenabled, then it converts the message object passed as parameter to a string by invoking the appropriateObjectRenderer. It proceeds to call all the registered appenders in this category and also higher in the hierarchy depending on the value of the additivity flag.WARNING Note that passing a
Throwableto this method will print the name of the Throwable but no stack trace. To print a stack trace use theCategory.info(Object, Throwable)form instead. -
info
Log a message object with theINFOlevel including the stack trace of theThrowabletpassed as parameter.See
Category.info(Object)for more detailed information. -
isAttached
Is the appender passed as parameter attached to this category?- Specified by:
isAttachedin interfaceAppenderAttachable- Overrides:
isAttachedin classCategory
-
isDebugEnabled
public boolean isDebugEnabled()Check whether this category is enabled for theDEBUGLevel.This function is intended to lessen the computational cost of disabled log debug statements.
For some
catCategory object, when you write,cat.debug("This is entry number: " + i);You incur the cost constructing the message, concatenatiion 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 category is debug enabled twice. Once inisDebugEnabledand once in thedebug. This is an insignificant overhead since evaluating a category takes about 1%% of the time it takes to actually log.- Overrides:
isDebugEnabledin classCategory- Returns:
- boolean -
trueif this category is debug enabled,falseotherwise.
-
isEnabledFor
Check whether this category is enabled for a givenLevelpassed as parameter.See also
Category.isDebugEnabled().- Overrides:
isEnabledForin classCategory- Returns:
- boolean True if this category is enabled for
level.
-
isInfoEnabled
public boolean isInfoEnabled()Check whether this category is enabled for the info Level. See alsoCategory.isDebugEnabled().- Overrides:
isInfoEnabledin classCategory- Returns:
- boolean -
trueif this category is enabled for level info,falseotherwise.
-
l7dlog
Log a localized message. The user supplied parameterkeyis replaced by its localized version from the resource bundle. -
l7dlog
Log a localized and parameterized message. First, the user suppliedkeyis searched in the resource bundle. Next, the resulting pattern is formatted usingMessageFormat.format(String, Object[])method with the user supplied object arrayparams. -
log
This generic form is intended to be used by wrappers. -
log
This generic form is intended to be used by wrappers. -
log
This is the most generic printing method. It is intended to be invoked by wrapper classes. -
removeAllAppenders
public void removeAllAppenders()Remove all previously added appenders from this Category instance.This is useful when re-reading configuration information.
- Specified by:
removeAllAppendersin interfaceAppenderAttachable- Overrides:
removeAllAppendersin classCategory
-
removeAppender
Remove the appender passed as parameter form the list of appenders.- Specified by:
removeAppenderin interfaceAppenderAttachable- Overrides:
removeAppenderin classCategory
-
removeAppender
Remove the appender with the name passed as parameter form the list of appenders.- Specified by:
removeAppenderin interfaceAppenderAttachable- Overrides:
removeAppenderin classCategory
-
setLevel
Set the level of this Category. If you are passing any ofLevel.DEBUG,Level.INFO,Level.WARN,Level.ERROR,Level.FATALas a parameter, you need to case them as Level.As in
logger.setLevel((Level) Level.DEBUG);
Null values are admitted.
-
setPriority
Set the level of this Category.Null values are admitted.
- Overrides:
setPriorityin classCategory
-
setResourceBundle
Set the resource bundle to be used with localized logging methodsCategory.l7dlog(Priority, String, Throwable)andCategory.l7dlog(Priority, String, Object[], Throwable).- Overrides:
setResourceBundlein classCategory
-
warn
Log a message object with theWARNLevel.This method first checks if this category is
WARNenabled by comparing the level of this category withWARNLevel. If the category isWARNenabled, then it converts the message object passed as parameter to a string by invoking the appropriateObjectRenderer. It proceeds to call all the registered appenders in this category and also higher in the hieararchy depending on the value of the additivity flag.WARNING Note that passing a
Throwableto this method will print the name of the Throwable but no stack trace. To print a stack trace use theCategory.warn(Object, Throwable)form instead. -
warn
Log a message with theWARNlevel including the stack trace of theThrowabletpassed as parameter.See
Category.warn(Object)for more detailed information. -
trace
Log a message object with theTRACElevel. -
trace
Log a message object with theTRACElevel including the stack trace of theThrowabletpassed as parameter.See
Category.debug(Object)form for more detailed information. -
isTraceEnabled
public boolean isTraceEnabled()Check whether this category is enabled for the TRACE Level.- Overrides:
isTraceEnabledin classLogger- Returns:
- boolean -
trueif this category is enabled for level TRACE,falseotherwise.
-