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 TypeMethodDescriptionvoid
addAppender
(Appender newAppender) AddnewAppender
to the list of appenders of this Category instance.void
void
callAppenders
(LoggingEvent event) Call the appenders in the hierrachy starting atthis
.void
Log a message object with theDEBUG
level.void
Log a message object with theDEBUG
level including the stack trace of theThrowable
t
passed as parameter.void
Log a message object with theERROR
Level.void
Log a message object with theERROR
level including the stack trace of theThrowable
t
passed as parameter.void
Log a message object with theFATAL
Level.void
Log a message object with theFATAL
level including the stack trace of theThrowable
t
passed 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 inheritedResourceBundle
for this category.void
Log a message object with theINFO
Level.void
Log a message object with theINFO
level including the stack trace of theThrowable
t
passed as parameter.boolean
isAttached
(Appender appender) Is the appender passed as parameter attached to this category?boolean
Check whether this category is enabled for theDEBUG
Level.boolean
isEnabledFor
(Priority level) Check whether this category is enabled for a givenLevel
passed as parameter.boolean
Check whether this category is enabled for the info Level.boolean
Check whether this category is enabled for the TRACE Level.void
Log a localized and parameterized message.void
Log a localized message.void
This is the most generic printing method.void
This generic form is intended to be used by wrappers.void
This generic form is intended to be used by wrappers.void
Remove all previously added appenders from this Category instance.void
removeAppender
(String name) Remove the appender with the name passed as parameter form the list of appenders.void
removeAppender
(Appender appender) Remove the appender passed as parameter form the list of appenders.void
Set the level of this Category.void
setPriority
(Priority priority) Set the level of this Category.void
setResourceBundle
(ResourceBundle bundle) Set the resource bundle to be used with localized logging methodsCategory.l7dlog(Priority,String,Throwable)
andCategory.l7dlog(Priority,String,Object[],Throwable)
.void
Log a message object with theTRACE
level.void
Log a message object with theTRACE
level including the stack trace of theThrowable
t
passed as parameter.void
Log a message object with theWARN
Level.void
Methods inherited from class org.apache.log4j.Logger
getLogger, getLogger, getLogger, getRootLogger
Methods 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
AddnewAppender
to the list of appenders of this Category instance.If
newAppender
is already in the list of appenders, then it won't be added again.- Specified by:
addAppender
in interfaceAppenderAttachable
- Overrides:
addAppender
in classCategory
-
assertLog
Ifassertion
parameter isfalse
, then logsmsg
as anerror
statement.The
assert
method has been renamed toassertLog
becauseassert
is 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:
callAppenders
in classCategory
- Parameters:
event
- the event to log.
-
debug
Log a message object with theDEBUG
level.This method first checks if this category is
DEBUG
enabled by comparing the level of this category with theDEBUG
level. If this category isDEBUG
enabled, 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
Throwable
to this method will print the name of theThrowable
but no stack trace. To print a stack trace use theCategory.debug(Object, Throwable)
form instead. -
debug
Log a message object with theDEBUG
level including the stack trace of theThrowable
t
passed as parameter.See
Category.debug(Object)
form for more detailed information. -
error
Log a message object with theERROR
Level.This method first checks if this category is
ERROR
enabled by comparing the level of this category withERROR
Level. If this category isERROR
enabled, 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
Throwable
to this method will print the name of theThrowable
but no stack trace. To print a stack trace use theCategory.error(Object, Throwable)
form instead. -
error
Log a message object with theERROR
level including the stack trace of theThrowable
t
passed as parameter.See
Category.error(Object)
form for more detailed information. -
fatal
Log a message object with theFATAL
Level.This method first checks if this category is
FATAL
enabled by comparing the level of this category withFATAL
Level. If the category isFATAL
enabled, 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
Throwable
to 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 theFATAL
level including the stack trace of theThrowable
t
passed 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 aNullEnumeration
is returned.- Specified by:
getAllAppenders
in interfaceAppenderAttachable
- Overrides:
getAllAppenders
in 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
null
otherwise.- Specified by:
getAppender
in interfaceAppenderAttachable
- Overrides:
getAppender
in 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:
getEffectiveLevel
in classCategory
-
getChainedPriority
- Overrides:
getChainedPriority
in classCategory
-
getResourceBundle
Return the inheritedResourceBundle
for 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
null
is returned.- Overrides:
getResourceBundle
in classCategory
-
info
Log a message object with theINFO
Level.This method first checks if this category is
INFO
enabled by comparing the level of this category withINFO
Level. If the category isINFO
enabled, 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
Throwable
to 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 theINFO
level including the stack trace of theThrowable
t
passed as parameter.See
Category.info(Object)
for more detailed information. -
isAttached
Is the appender passed as parameter attached to this category?- Specified by:
isAttached
in interfaceAppenderAttachable
- Overrides:
isAttached
in classCategory
-
isDebugEnabled
public boolean isDebugEnabled()Check whether this category is enabled for theDEBUG
Level.This function is intended to lessen the computational cost of disabled log debug statements.
For some
cat
Category 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 thecat
is debug enabled, you will incur the cost of evaluating whether the category is debug enabled twice. Once inisDebugEnabled
and once in thedebug
. This is an insignificant overhead since evaluating a category takes about 1%% of the time it takes to actually log.- Overrides:
isDebugEnabled
in classCategory
- Returns:
- boolean -
true
if this category is debug enabled,false
otherwise.
-
isEnabledFor
Check whether this category is enabled for a givenLevel
passed as parameter. See alsoCategory.isDebugEnabled()
.- Overrides:
isEnabledFor
in 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:
isInfoEnabled
in classCategory
- Returns:
- boolean -
true
if this category is enabled for level info,false
otherwise.
-
l7dlog
Log a localized message. The user supplied parameterkey
is replaced by its localized version from the resource bundle. -
l7dlog
Log a localized and parameterized message. First, the user suppliedkey
is 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:
removeAllAppenders
in interfaceAppenderAttachable
- Overrides:
removeAllAppenders
in classCategory
-
removeAppender
Remove the appender passed as parameter form the list of appenders.- Specified by:
removeAppender
in interfaceAppenderAttachable
- Overrides:
removeAppender
in classCategory
-
removeAppender
Remove the appender with the name passed as parameter form the list of appenders.- Specified by:
removeAppender
in interfaceAppenderAttachable
- Overrides:
removeAppender
in classCategory
-
setLevel
Set the level of this Category. If you are passing any ofLevel.DEBUG
,Level.INFO
,Level.WARN
,Level.ERROR
,Level.FATAL
as 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:
setPriority
in classCategory
-
setResourceBundle
Set the resource bundle to be used with localized logging methodsCategory.l7dlog(Priority,String,Throwable)
andCategory.l7dlog(Priority,String,Object[],Throwable)
.- Overrides:
setResourceBundle
in classCategory
-
warn
Log a message object with theWARN
Level.This method first checks if this category is
WARN
enabled by comparing the level of this category withWARN
Level. If the category isWARN
enabled, 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
Throwable
to 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 theWARN
level including the stack trace of theThrowable
t
passed as parameter.See
Category.warn(Object)
for more detailed information. -
trace
Log a message object with theTRACE
level. -
trace
Log a message object with theTRACE
level including the stack trace of theThrowable
t
passed 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:
isTraceEnabled
in classLogger
- Returns:
- boolean -
true
if this category is enabled for level TRACE,false
otherwise.
-