Class Category
- java.lang.Object
-
- org.apache.log4j.Category
-
- All Implemented Interfaces:
org.apache.log4j.spi.AppenderAttachable,PaxLoggingManagerAwareLogger
- Direct Known Subclasses:
Logger
public abstract class Category extends Object implements org.apache.log4j.spi.AppenderAttachable, PaxLoggingManagerAwareLogger
This class has been deprecated and replaced by theLoggersubclass. It will be kept around to preserve backward compatibility until mid 2003.Loggeris a subclass of Category, i.e. it extends Category. In other words, a logger is a category. Thus, all operations that can be performed on a category can be performed on a logger. Internally, whenever log4j is asked to produce a Category object, it will instead produce a Logger object. Log4j 1.2 will never produce Category objects but onlyLoggerinstances. In order to preserve backward compatibility, methods that previously accepted category objects still continue to accept category objects.For example, the following are all legal and will work as expected.
// Deprecated form: Category cat = Category.getInstance("foo.bar") // Preferred form for retrieving loggers: Logger logger = Logger.getLogger("foo.bar")The first form is deprecated and should be avoided.
There is absolutely no need for new client code to use or refer to the
Categoryclass. Whenever possible, please avoid referring to it or using it.See the short manual for an introduction on this class.
See the document entitled preparing for log4j 1.3 for a more detailed discussion.
- Author:
- Ceki Gülcü, Anders Kristensen
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanadditiveAdditivity is set to true by default, that is children inherit the appenders of their ancestors by default.protected org.apache.log4j.LevellevelThe assigned level of this category.protected static StringLOG4J_FQCNprotected PaxLoggerm_delegateprotected static PaxLoggingManagerm_paxLoggingprotected StringnameThe name of this category.protected CategoryparentThe parent of this category.protected org.apache.log4j.spi.LoggerRepositoryrepository
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddAppender(org.apache.log4j.Appender newAppender)AddnewAppenderto the list of appenders of this Category instance.voidassertLog(boolean assertion, String msg)voidcallAppenders(org.apache.log4j.spi.LoggingEvent event)Call the appenders in the hierrachy starting atthis.static voidconfigurePaxLoggingManager(PaxLoggingManager manager)Static method is different than usual, because here logger is also a factory.voiddebug(Object message)Log a message object with theDEBUGlevel.voiddebug(Object messagePattern, Object arg)Log a message with theDEBUGlevel with message formatting done according to the value ofmessagePatternandargparameters.voiddebug(Object message, Throwable t)Log a message object with theDEBUGlevel including the stack trace of theThrowabletpassed as parameter.voiddebug(String messagePattern, Object arg1, Object arg2)Log a message with theDEBUGlevel with message formatting done according to the messagePattern and the arguments arg1 and arg2.voiderror(Object message)Log a message object with theERRORLevel.voiderror(Object messagePattern, Object arg)Log a message with theERRORlevel with message formatting done according to the value ofmessagePatternandargparameters.voiderror(Object message, Throwable t)Log a message object with theERRORlevel including the stack trace of theThrowabletpassed as parameter.voiderror(String messagePattern, Object arg1, Object arg2)Log a message with theERRORlevel with message formatting done according to the messagePattern and the arguments arg1 and arg2.static Loggerexists(String name)Deprecated.Please useLogManager.exists(java.lang.String)instead.voidfatal(Object message)Log a message object with theFATALLevel.voidfatal(Object messagePattern, Object arg)Log a message with theFATALlevel with message formatting done according to the value ofmessagePatternandargparameters.voidfatal(Object message, Throwable t)Log a message object with theFATALlevel including the stack trace of theThrowabletpassed as parameter.voidfatal(String messagePattern, Object arg1, Object arg2)Log a message with theFATALlevel with message formatting done according to the messagePattern and the arguments arg1 and arg2.protected voidforcedLog(String fqcn, Priority level, Object message, Throwable t)This method creates a new logging event and logs the event without further checks.booleangetAdditivity()Get the additivity flag for this Category instance.EnumerationgetAllAppenders()Get the appenders contained in this category as anEnumeration.org.apache.log4j.AppendergetAppender(String name)Look for the appender named asname.PrioritygetChainedPriority()Deprecated.Please use the thegetEffectiveLevel()method instead.static EnumerationgetCurrentCategories()Deprecated.Please useLogManager.getCurrentLoggers()instead.static org.apache.log4j.spi.LoggerRepositorygetDefaultHierarchy()Deprecated.Please useLogManager.getLoggerRepository()instead.org.apache.log4j.LevelgetEffectiveLevel()Starting from this category, search the category hierarchy for a non-null level and return it.org.apache.log4j.spi.LoggerRepositorygetHierarchy()Deprecated.Please usegetLoggerRepository()instead.static CategorygetInstance(Class clazz)Deprecated.Please make sure to useLogger.getLogger(Class)instead.static CategorygetInstance(String name)Deprecated.Make sure to useLogger.getLogger(String)instead.org.apache.log4j.LevelgetLevel()Returns the assignedLevel, if any, for this Category.org.apache.log4j.spi.LoggerRepositorygetLoggerRepository()Return the theLoggerRepositorywhere thisCategoryis attached.StringgetName()Return the category name.CategorygetParent()Returns the parent of this category.org.apache.log4j.LevelgetPriority()Deprecated.Please usegetLevel()instead.ResourceBundlegetResourceBundle()Return the inheritedResourceBundlefor this category.protected StringgetResourceBundleString(String key)Returns the string resource coresponding tokeyin this category's inherited resource bundle.static CategorygetRoot()Deprecated.Please useLogger.getRootLogger()instead.voidinfo(Object message)Log a message object with theINFOLevel.voidinfo(Object messagePattern, Object arg)Log a message with theINFOlevel with message formatting done according to the value ofmessagePatternandargparameters.voidinfo(Object message, Throwable t)Log a message object with theINFOlevel including the stack trace of theThrowabletpassed as parameter.voidinfo(String messagePattern, Object arg1, Object arg2)Log a message with theINFOlevel with message formatting done according to the messagePattern and the arguments arg1 and arg2.booleanisAttached(org.apache.log4j.Appender appender)Is the appender passed as parameter attached to this category?booleanisDebugEnabled()Check whether this category is enabled for theDEBUGLevel.booleanisEnabledFor(Priority level)Check whether this category is enabled for a givenLevelpassed as parameter.booleanisErrorEnabled()Check whether this category is enabled for the ERROR Level.booleanisInfoEnabled()Check whether this category is enabled for the info Level.booleanisTraceEnabled()Check whether this category is enabled for the TRACE Level.booleanisWarnEnabled()Check whether this category is enabled for the WARN Level.voidl7dlog(Priority priority, String key, Object[] params, Throwable t)Log a localized and parameterized message.voidl7dlog(Priority priority, String key, Throwable t)Log a localized message.voidlog(String callerFQCN, Priority level, Object message, Throwable t)This is the most generic printing method.voidlog(Priority priority, Object message)This generic form is intended to be used by wrappers.voidlog(Priority priority, Object message, Throwable t)This generic form is intended to be used by wrappers.voidremoveAllAppenders()Remove 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(org.apache.log4j.Appender appender)Remove the appender passed as parameter form the list of appenders.voidsetAdditivity(boolean additive)Set the additivity flag for this Category instance.voidsetLevel(org.apache.log4j.Level level)Set the level of this Category.voidsetPaxLoggingManager(PaxLoggingManager loggingManager)Configures aPaxLoggingManagerthat from now on can be used toobtain a non-fallback loggerthat given logger is delegating to.voidsetPriority(Priority priority)Deprecated.Please usesetLevel(org.apache.log4j.Level)instead.voidsetResourceBundle(ResourceBundle bundle)Set the resource bundle to be used with localized logging methodsl7dlog(Priority, String, Throwable)andl7dlog(Priority, String, Object[], Throwable).static voidshutdown()Deprecated.Please useLogManager.shutdown()instead.voidtrace(Object message)Log a message object with theTRACElevel.voidtrace(Object messagePattern, Object arg)Log a message with theTRACElevel with message formatting done according to the value ofmessagePatternandargparameters.voidtrace(Object message, Throwable t)Log a message object with theTRACElevel including the stack trace of theThrowabletpassed as parameter.voidtrace(String messagePattern, Object arg1, Object arg2)Log a message with theTRACElevel with message formatting done according to the messagePattern and the arguments arg1 and arg2.voidwarn(Object message)Log a message object with theWARNLevel.voidwarn(Object messagePattern, Object arg)Log a message with theWARNlevel with message formatting done according to the value ofmessagePatternandargparameters.voidwarn(Object message, Throwable t)voidwarn(String messagePattern, Object arg1, Object arg2)Log a message with theWARNlevel with message formatting done according to the messagePattern and the arguments arg1 and arg2.
-
-
-
Field Detail
-
LOG4J_FQCN
protected static final String LOG4J_FQCN
-
m_paxLogging
protected static PaxLoggingManager m_paxLogging
-
m_delegate
protected PaxLogger m_delegate
-
name
protected String name
The name of this category.
-
level
protected volatile org.apache.log4j.Level level
The assigned level of this category. Thelevelvariable need not be assigned a value in which case it is inherited form the hierarchy.
-
parent
protected volatile Category parent
The parent of this category. All categories have at least one ancestor which is the root category.
-
repository
protected org.apache.log4j.spi.LoggerRepository repository
-
additive
protected boolean additive
Additivity is set to true by default, that is children inherit the appenders of their ancestors by default. If this variable is set tofalsethen the appenders found in the ancestors of this category are not used. However, the children of this category will inherit its appenders, unless the children have their additivity flag set tofalsetoo. See the user manual for more details.
-
-
Constructor Detail
-
Category
protected Category(String name)
This constructor created a newCategoryinstance and sets its name.It is intended to be used by sub-classes only. You should not create categories directly.
- Parameters:
name- The name of the category.
-
-
Method Detail
-
configurePaxLoggingManager
public static void configurePaxLoggingManager(PaxLoggingManager manager)
Static method is different than usual, because here logger is also a factory.- Parameters:
manager-
-
setPaxLoggingManager
public void setPaxLoggingManager(PaxLoggingManager loggingManager)
Description copied from interface:PaxLoggingManagerAwareLoggerConfigures aPaxLoggingManagerthat from now on can be used toobtain a non-fallback loggerthat given logger is delegating to. This method is called in activator of pax-logging-api to ensure that loggers that may already been created from pax-logging adjusted facades/factories actually delegate to realPaxLoggingService. This is especially visible in pax-exam tests, where pax-logging-api's SLF4J classes are already used by pax-exam itself before even starting OSGi framework.- Specified by:
setPaxLoggingManagerin interfacePaxLoggingManagerAwareLogger
-
addAppender
public void addAppender(org.apache.log4j.Appender newAppender)
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 interfaceorg.apache.log4j.spi.AppenderAttachable
-
assertLog
public void assertLog(boolean assertion, String msg)Ifassertionparameter isfalse, then logsmsgas anerrorstatement.The
assertmethod has been renamed toassertLogbecauseassertis a language reserved word in JDK 1.4.- Parameters:
assertion-msg- The message to print ifassertionis false.- Since:
- 1.2
-
callAppenders
public void callAppenders(org.apache.log4j.spi.LoggingEvent event)
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.
- Parameters:
event- the event to log.
-
debug
public void debug(Object message)
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 thedebug(Object, Throwable)form instead.- Parameters:
message- the message object to log.
-
debug
public void debug(Object message, Throwable t)
Log a message object with theDEBUGlevel 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.
-
debug
public void debug(Object messagePattern, Object arg)
Log a message with theDEBUGlevel with message formatting done according to the value ofmessagePatternandargparameters.This form avoids superflous parameter construction. Whenever possible, you should use this form instead of constructing the message parameter using string concatenation.
- Parameters:
messagePattern- The message pattern which will be parsed and formattedarg- The argument to replace the formatting element, i,e, the '{}' pair withinmessagePattern.- Since:
- 1.3
-
debug
public void debug(String messagePattern, Object arg1, Object arg2)
Log a message with theDEBUGlevel with message formatting done according to the messagePattern and the arguments arg1 and arg2.This form avoids superflous parameter construction. Whenever possible, you should use this form instead of constructing the message parameter using string concatenation.
- Parameters:
messagePattern- The message pattern which will be parsed and formattedarg1- The first argument to replace the first formatting elementarg2- The second argument to replace the second formatting element- Since:
- 1.3
-
trace
public void trace(Object message)
Log a message object with theTRACElevel.- Parameters:
message- the message object to log.- Since:
- 1.2.12
- See Also:
for an explanation of the logic applied.
-
trace
public void trace(Object message, Throwable t)
Log a message object with theTRACElevel 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.- Since:
- 1.2.12
-
trace
public void trace(Object messagePattern, Object arg)
Log a message with theTRACElevel with message formatting done according to the value ofmessagePatternandargparameters.This form avoids superflous parameter construction. Whenever possible, you should use this form instead of constructing the message parameter using string concatenation.
- Parameters:
messagePattern- The message pattern which will be parsed and formattedarg- The argument to replace the formatting element, i,e, the '{}' pair withinmessagePattern.- Since:
- 1.3
-
trace
public void trace(String messagePattern, Object arg1, Object arg2)
Log a message with theTRACElevel with message formatting done according to the messagePattern and the arguments arg1 and arg2.This form avoids superflous parameter construction. Whenever possible, you should use this form instead of constructing the message parameter using string concatenation.
- Parameters:
messagePattern- The message pattern which will be parsed and formattedarg1- The first argument to replace the first formatting elementarg2- The second argument to replace the second formatting element- Since:
- 1.3
-
isErrorEnabled
public boolean isErrorEnabled()
Check whether this category is enabled for the ERROR Level. See alsoisDebugEnabled().- Returns:
- boolean -
trueif this category is enabled for level ERROR,falseotherwise.
-
error
public void error(Object message)
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 theerror(Object, Throwable)form instead.- Parameters:
message- the message object to log
-
error
public void error(Object message, Throwable t)
Log a message object with theERRORlevel including the stack trace of theThrowabletpassed as parameter.See
error(Object)form for more detailed information.- Parameters:
message- the message object to log.t- the exception to log, including its stack trace.
-
error
public void error(Object messagePattern, Object arg)
Log a message with theERRORlevel with message formatting done according to the value ofmessagePatternandargparameters.This form avoids superflous parameter construction. Whenever possible, you should use this form instead of constructing the message parameter using string concatenation.
- Parameters:
messagePattern- The message pattern which will be parsed and formattedarg- The argument to replace the formatting element, i,e, the '{}' pair withinmessagePattern.- Since:
- 1.3
-
error
public void error(String messagePattern, Object arg1, Object arg2)
Log a message with theERRORlevel with message formatting done according to the messagePattern and the arguments arg1 and arg2.This form avoids superflous parameter construction. Whenever possible, you should use this form instead of constructing the message parameter using string concatenation.
- Parameters:
messagePattern- The message pattern which will be parsed and formattedarg1- The first argument to replace the first formatting elementarg2- The second argument to replace the second formatting element- Since:
- 1.3
-
exists
public static Logger exists(String name)
Deprecated.Please useLogManager.exists(java.lang.String)instead.If the named category exists (in the default hierarchy) then it returns a reference to the category, otherwise it returnsnull.- Since:
- 0.8.5
-
fatal
public void fatal(Object message)
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 thefatal(Object, Throwable)form instead.- Parameters:
message- the message object to log
-
fatal
public void fatal(Object messagePattern, Object arg)
Log a message with theFATALlevel with message formatting done according to the value ofmessagePatternandargparameters.This form avoids superflous parameter construction. Whenever possible, you should use this form instead of constructing the message parameter using string concatenation.
- Parameters:
messagePattern- The message pattern which will be parsed and formattedarg- The argument to replace the formatting element, i,e, the '{}' pair withinmessagePattern.- Since:
- 1.3
-
fatal
public void fatal(String messagePattern, Object arg1, Object arg2)
Log a message with theFATALlevel with message formatting done according to the messagePattern and the arguments arg1 and arg2.This form avoids superflous parameter construction. Whenever possible, you should use this form instead of constructing the message parameter using string concatenation.
- Parameters:
messagePattern- The message pattern which will be parsed and formattedarg1- The first argument to replace the first formatting elementarg2- The second argument to replace the second formatting element- Since:
- 1.3
-
fatal
public void fatal(Object message, Throwable t)
Log a message object with theFATALlevel including the stack trace of theThrowabletpassed as parameter.See
fatal(Object)for more detailed information.- Parameters:
message- the message object to log.t- the exception to log, including its stack trace.
-
forcedLog
protected void forcedLog(String fqcn, Priority level, Object message, Throwable t)
This method creates a new logging event and logs the event without further checks.
-
getAdditivity
public boolean getAdditivity()
Get the additivity flag for this Category instance.
-
getAllAppenders
public Enumeration getAllAppenders()
Get the appenders contained in this category as anEnumeration. If no appenders can be found, then aNullEnumerationis returned.- Specified by:
getAllAppendersin interfaceorg.apache.log4j.spi.AppenderAttachable- Returns:
- Enumeration An enumeration of the appenders in this category.
-
getAppender
public org.apache.log4j.Appender getAppender(String name)
Look for the appender named asname.Return the appender with that name if in the list. Return
nullotherwise.- Specified by:
getAppenderin interfaceorg.apache.log4j.spi.AppenderAttachable
-
getEffectiveLevel
public org.apache.log4j.Level 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.
-
getChainedPriority
public Priority getChainedPriority()
Deprecated.Please use the thegetEffectiveLevel()method instead.
-
getCurrentCategories
public static Enumeration getCurrentCategories()
Deprecated.Please useLogManager.getCurrentLoggers()instead.Returns all the currently defined categories in the default hierarchy as anEnumeration.The root category is not included in the returned
Enumeration.
-
getDefaultHierarchy
public static org.apache.log4j.spi.LoggerRepository getDefaultHierarchy()
Deprecated.Please useLogManager.getLoggerRepository()instead.Return the default Hierarchy instance.- Since:
- 1.0
-
getHierarchy
public org.apache.log4j.spi.LoggerRepository getHierarchy()
Deprecated.Please usegetLoggerRepository()instead.Return the theHierarchywhere thisCategoryinstance is attached.- Since:
- 1.1
-
getLoggerRepository
public org.apache.log4j.spi.LoggerRepository getLoggerRepository()
Return the theLoggerRepositorywhere thisCategoryis attached.- Since:
- 1.2
-
getInstance
public static Category getInstance(String name)
Deprecated.Make sure to useLogger.getLogger(String)instead.
-
getInstance
public static Category getInstance(Class clazz)
Deprecated.Please make sure to useLogger.getLogger(Class)instead.
-
getName
public final String getName()
Return the category name.
-
getParent
public final Category getParent()
Returns the parent of this category. Note that the parent of a given category may change during the lifetime of the category.The root category will return
null.- Since:
- 1.2
-
getLevel
public final org.apache.log4j.Level getLevel()
Returns the assignedLevel, if any, for this Category.- Returns:
- Level - the assigned Level, can be
null.
-
getPriority
public final org.apache.log4j.Level getPriority()
Deprecated.Please usegetLevel()instead.
-
getRoot
public static final Category getRoot()
Deprecated.Please useLogger.getRootLogger()instead.
-
getResourceBundle
public ResourceBundle 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.- Since:
- 0.9.0
-
getResourceBundleString
protected String getResourceBundleString(String key)
Returns the string resource coresponding tokeyin this category's inherited resource bundle. See alsogetResourceBundle().If the resource cannot be found, then an
errormessage will be logged complaining about the missing resource.
-
info
public void info(Object message)
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 theinfo(Object, Throwable)form instead.- Parameters:
message- the message object to log
-
info
public void info(Object messagePattern, Object arg)
Log a message with theINFOlevel with message formatting done according to the value ofmessagePatternandargparameters.This form avoids superflous parameter construction. Whenever possible, you should use this form instead of constructing the message parameter using string concatenation.
- Parameters:
messagePattern- The message pattern which will be parsed and formattedarg- The argument to replace the formatting element, i,e, the '{}' pair withinmessagePattern.- Since:
- 1.3
-
info
public void info(String messagePattern, Object arg1, Object arg2)
Log a message with theINFOlevel with message formatting done according to the messagePattern and the arguments arg1 and arg2.This form avoids superflous parameter construction. Whenever possible, you should use this form instead of constructing the message parameter using string concatenation.
- Parameters:
messagePattern- The message pattern which will be parsed and formattedarg1- The first argument to replace the first formatting elementarg2- The second argument to replace the second formatting element- Since:
- 1.3
-
info
public void info(Object message, Throwable t)
Log a message object with theINFOlevel including the stack trace of theThrowabletpassed as parameter.See
info(Object)for more detailed information.- Parameters:
message- the message object to log.t- the exception to log, including its stack trace.
-
isAttached
public boolean isAttached(org.apache.log4j.Appender appender)
Is the appender passed as parameter attached to this category?- Specified by:
isAttachedin interfaceorg.apache.log4j.spi.AppenderAttachable
-
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.- Returns:
- boolean -
trueif this category is debug enabled,falseotherwise.
-
isTraceEnabled
public boolean isTraceEnabled()
Check whether this category is enabled for the TRACE Level. See alsoisDebugEnabled().- Returns:
- boolean -
trueif this category is enabled for level TRACE,falseotherwise.
-
isEnabledFor
public boolean isEnabledFor(Priority level)
Check whether this category is enabled for a givenLevelpassed as parameter.See also
isDebugEnabled().- 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 alsoisDebugEnabled().- Returns:
- boolean -
trueif this category is enabled for level info,falseotherwise.
-
l7dlog
public void l7dlog(Priority priority, String key, Throwable t)
Log a localized message. The user supplied parameterkeyis replaced by its localized version from the resource bundle.- Since:
- 0.8.4
- See Also:
setResourceBundle(java.util.ResourceBundle)
-
l7dlog
public void l7dlog(Priority priority, String key, Object[] params, Throwable t)
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.- Since:
- 0.8.4
-
log
public void log(Priority priority, Object message, Throwable t)
This generic form is intended to be used by wrappers.
-
log
public void log(Priority priority, Object message)
This generic form is intended to be used by wrappers.
-
log
public void log(String callerFQCN, Priority level, Object message, Throwable t)
This is the most generic printing method. It is intended to be invoked by wrapper classes.- Parameters:
callerFQCN- The wrapper class' fully qualified class name.level- The level of the logging request.message- The message of the logging request.t- The throwable of the logging request, may be null.
-
removeAllAppenders
public void removeAllAppenders()
Remove all previously added appenders from this Category instance.This is useful when re-reading configuration information.
- Specified by:
removeAllAppendersin interfaceorg.apache.log4j.spi.AppenderAttachable
-
removeAppender
public void removeAppender(org.apache.log4j.Appender appender)
Remove the appender passed as parameter form the list of appenders.- Specified by:
removeAppenderin interfaceorg.apache.log4j.spi.AppenderAttachable- Since:
- 0.8.2
-
removeAppender
public void removeAppender(String name)
Remove the appender with the name passed as parameter form the list of appenders.- Specified by:
removeAppenderin interfaceorg.apache.log4j.spi.AppenderAttachable- Since:
- 0.8.2
-
setAdditivity
public void setAdditivity(boolean additive)
Set the additivity flag for this Category instance.- Since:
- 0.8.1
-
setLevel
public void setLevel(org.apache.log4j.Level level)
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
public void setPriority(Priority priority)
Deprecated.Please usesetLevel(org.apache.log4j.Level)instead.Set the level of this Category.Null values are admitted.
-
setResourceBundle
public void setResourceBundle(ResourceBundle bundle)
Set the resource bundle to be used with localized logging methodsl7dlog(Priority, String, Throwable)andl7dlog(Priority, String, Object[], Throwable).- Since:
- 0.8.4
-
shutdown
public static void shutdown()
Deprecated.Please useLogManager.shutdown()instead.Calling this method will safely close and remove all appenders in all the categories including root contained in the default hierachy.Some appenders such as
SocketAppenderandAsyncAppenderneed to be closed before the application exists. Otherwise, pending logging events might be lost.The
shutdownmethod is careful to close nested appenders before closing regular appenders. This is allows configurations where a regular appender is attached to a category and again to a nested appender.- Since:
- 1.0
-
isWarnEnabled
public boolean isWarnEnabled()
Check whether this category is enabled for the WARN Level. See alsoisDebugEnabled().- Returns:
- boolean -
trueif this category is enabled for level WARN,falseotherwise.
-
warn
public void warn(Object message)
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 thewarn(Object, Throwable)form instead.- Parameters:
message- the message object to log.
-
warn
public void warn(Object message, Throwable t)
Log a message with theWARNlevel including the stack trace of theThrowabletpassed as parameter.See
warn(Object)for more detailed information.- Parameters:
message- the message object to log.t- the exception to log, including its stack trace.
-
warn
public void warn(Object messagePattern, Object arg)
Log a message with theWARNlevel with message formatting done according to the value ofmessagePatternandargparameters.This form avoids superflous parameter construction. Whenever possible, you should use this form instead of constructing the message parameter using string concatenation.
- Parameters:
messagePattern- The message pattern which will be parsed and formattedarg- The argument to replace the formatting element, i,e, the '{}' pair withinmessagePattern.- Since:
- 1.3
-
warn
public void warn(String messagePattern, Object arg1, Object arg2)
Log a message with theWARNlevel with message formatting done according to the messagePattern and the arguments arg1 and arg2.This form avoids superflous parameter construction. Whenever possible, you should use this form instead of constructing the message parameter using string concatenation.
- Parameters:
messagePattern- The message pattern which will be parsed and formattedarg1- The first argument to replace the first formatting elementarg2- The second argument to replace the second formatting element- Since:
- 1.3
-
-