Package org.apache.log4j
Class Category
java.lang.Object
org.apache.log4j.Category
- All Implemented Interfaces:
AppenderAttachable
- Direct Known Subclasses:
Logger
Implementation of the Category class for compatibility, despite it having been deprecated a long, long time ago.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) AppenderAttachableImpl
protected boolean
Additivity is set to true by default, that is children inherit the appenders of their ancestors by default.protected ResourceBundle
Resource bundle for localized messages.private static final String
protected Level
The assigned level of this category.private final Logger
protected String
The name of this category.protected Category
The parent of this category.private RendererMap
protected LoggerRepository
Categories need to know what Hierarchy they are in. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAppender
(Appender appender) AddnewAppender
to the list of appenders of this Category instance.void
void
callAppenders
(LoggingEvent event) Call the appenders in the hierrachy starting atthis
.(package private) void
Closes all attached appenders implementing the AppenderAttachable interface.private static Message
createMessage
(Object message) void
void
void
void
static Logger
Deprecated.void
void
private void
fireRemoveAppenderEvent
(Appender appender) LoggerRepository forgot the fireRemoveAppenderEvent method, if using the stock Hierarchy implementation, then call its fireRemove.void
private <T> ObjectRenderer
boolean
Get all the Log4j 1.x appenders contained in this category as anEnumeration
.getAppender
(String name) Look for the appender named asname
.static Enumeration
Deprecated.Please useLogManager.getCurrentLoggers()
instead.static LoggerRepository
Deprecated.Please useLogManager.getLoggerRepository()
instead.Deprecated.Please usegetLoggerRepository()
instead.static Category
getInstance
(Class clazz) static Category
getInstance
(String name) final Level
getLevel()
private String
getLevelStr
(Priority priority) (package private) Logger
Gets theLoggerRepository
where thisCategory
is attached.final String
getName()
final Category
final Level
static Category
getRoot()
private static String
getSubName
(String name) void
void
boolean
isAttached
(Appender appender) Is the appender passed as parameter attached to this category?boolean
boolean
isEnabledFor
(Priority level) private boolean
isEnabledFor
(Level level) boolean
boolean
boolean
boolean
void
void
void
void
void
(package private) void
void
Removes all previously added appenders from this Category instance.void
removeAppender
(String name) Removes the appender with the name passed as parameter form the list of appenders.void
removeAppender
(Appender appender) Removes the appender passed as parameter form the list of appenders.(package private) ObjectRenderer
searchInterfaces
(Class<?> c) void
setAdditivity
(boolean additivity) (package private) final void
setHierarchy
(LoggerRepository repository) Only the Hiearchy class can set the hiearchy of a category.void
private void
void
setPriority
(Priority priority) void
setResourceBundle
(ResourceBundle bundle) static void
shutdown()
Shuts down the current configuration.void
void
-
Field Details
-
FQCN
-
name
The name of this category. -
additive
protected boolean additiveAdditivity is set to true by default, that is children inherit the appenders of their ancestors by default. If this variable is set tofalse
then 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 tofalse
too. See the user manual for more details. -
level
The assigned level of this category. Thelevel
variable need not be assigned a value in which case it is inherited form the hierarchy. -
rendererMap
-
parent
The parent of this category. All categories have at least one ancestor which is the root category. -
bundle
Resource bundle for localized messages. -
logger
-
repository
Categories need to know what Hierarchy they are in. -
aai
-
-
Constructor Details
-
Category
Constructor used by Logger to specify a LoggerContext.- Parameters:
context
- The LoggerContext.name
- The name of the Logger.
-
Category
Category(Logger logger) -
Category
Constructor exposed by Log4j 1.2.- Parameters:
name
- The name of the Logger.
-
-
Method Details
-
exists
Deprecated.Please useLogManager.exists(String)
instead.Tests if the named category exists (in the default hierarchy).- Parameters:
name
- The name to test.- Returns:
- Whether the name exists.
- Since:
- 0.8.5
-
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
.- Returns:
- and Enumeration of the Categories.
-
getDefaultHierarchy
Deprecated.Please useLogManager.getLoggerRepository()
instead.Gets the default LoggerRepository instance.- Returns:
- the default LoggerRepository instance.
- Since:
- 1.0
-
getInstance
-
getInstance
-
getRoot
-
getSubName
-
shutdown
public static void shutdown()Shuts down the current configuration. -
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
- Parameters:
appender
- The Appender to add.
-
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.- Parameters:
assertion
- The assertion.msg
- The message to print ifassertion
is false.- Since:
- 1.2
-
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.
- Parameters:
event
- the event to log.
-
closeNestedAppenders
void closeNestedAppenders()Closes all attached appenders implementing the AppenderAttachable interface.- Since:
- 1.0
-
debug
-
debug
-
error
-
error
-
fatal
-
fatal
-
fireRemoveAppenderEvent
LoggerRepository forgot the fireRemoveAppenderEvent method, if using the stock Hierarchy implementation, then call its fireRemove. Custom repositories can implement HierarchyEventListener if they want remove notifications.- Parameters:
appender
- appender, may be null.
-
createMessage
-
forcedLog
-
get
-
getAdditivity
public boolean getAdditivity() -
getAllAppenders
Get all the Log4j 1.x appenders contained in this category as anEnumeration
. Log4j 2.x appenders are omitted.- Specified by:
getAllAppenders
in interfaceAppenderAttachable
- 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
- Parameters:
name
- The name of the Appender.- Returns:
- The Appender.
-
getChainedPriority
-
getEffectiveLevel
-
getHierarchy
Deprecated.Please usegetLoggerRepository()
instead.Gets theLoggerRepository
where thisCategory
instance is attached.- Since:
- 1.1
-
getLevel
-
getLevelStr
-
getLogger
Logger getLogger() -
getLoggerRepository
Gets theLoggerRepository
where thisCategory
is attached.- Since:
- 1.2
-
getName
-
getParent
-
getPriority
-
getResourceBundle
-
info
-
info
-
isAttached
Is the appender passed as parameter attached to this category?- Specified by:
isAttached
in interfaceAppenderAttachable
- Parameters:
appender
- The Appender to add.- Returns:
- true if the appender is attached.
-
isDebugEnabled
public boolean isDebugEnabled() -
isEnabledFor
-
isEnabledFor
-
isErrorEnabled
public boolean isErrorEnabled() -
isFatalEnabled
public boolean isFatalEnabled() -
isInfoEnabled
public boolean isInfoEnabled() -
isWarnEnabled
public boolean isWarnEnabled() -
l7dlog
-
l7dlog
-
log
-
log
-
log
-
maybeLog
-
removeAllAppenders
public void removeAllAppenders()Removes all previously added appenders from this Category instance.This is useful when re-reading configuration information.
- Specified by:
removeAllAppenders
in interfaceAppenderAttachable
-
removeAppender
Removes the appender passed as parameter form the list of appenders.- Specified by:
removeAppender
in interfaceAppenderAttachable
- Parameters:
appender
- The Appender to remove.- Since:
- 0.8.2
-
removeAppender
Removes the appender with the name passed as parameter form the list of appenders.- Specified by:
removeAppender
in interfaceAppenderAttachable
- Parameters:
name
- The Appender to remove.- Since:
- 0.8.2
-
searchInterfaces
-
setAdditivity
public void setAdditivity(boolean additivity) -
setHierarchy
Only the Hiearchy class can set the hiearchy of a category. Default package access is MANDATORY here. -
setLevel
-
setLevel
-
setPriority
-
setResourceBundle
-
warn
-
warn
-
LogManager.exists(String)
instead.