public class Category extends Object implements AppenderAttachable
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
additive
Additivity is set to true by default, that is children inherit the appenders of their ancestors by default.
|
protected ResourceBundle |
bundle
Resource bundle for localized messages.
|
protected Level |
level
The assigned level of this category.
|
protected String |
name
The name of this category.
|
protected Category |
parent
The parent of this category.
|
protected LoggerRepository |
repository
Categories need to know what Hierarchy they are in.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Category(LoggerContext context,
String name)
Constructor used by Logger to specify a LoggerContext.
|
protected |
Category(String name)
Constructor exposed by Log4j 1.2.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAppender(Appender appender)
Add
newAppender to the list of appenders of this Category instance. |
void |
assertLog(boolean assertion,
String msg)
|
void |
callAppenders(LoggingEvent event)
Call the appenders in the hierrachy starting at
this. |
void |
debug(Object message) |
void |
debug(Object message,
Throwable t) |
void |
error(Object message) |
void |
error(Object message,
Throwable t) |
static Logger |
exists(String name)
Deprecated.
Please use
LogManager.exists(String) instead. |
void |
fatal(Object message) |
void |
fatal(Object message,
Throwable t) |
void |
forcedLog(String fqcn,
Priority level,
Object message,
Throwable t) |
boolean |
getAdditivity() |
Enumeration |
getAllAppenders()
Get all the Log4j 1.x appenders contained in this category as an
Enumeration. |
Appender |
getAppender(String name)
Look for the appender named as
name. |
Priority |
getChainedPriority() |
static Enumeration |
getCurrentCategories()
Deprecated.
Please use
LogManager.getCurrentLoggers() instead. |
static LoggerRepository |
getDefaultHierarchy()
Deprecated.
Please use
LogManager.getLoggerRepository() instead. |
Level |
getEffectiveLevel() |
LoggerRepository |
getHierarchy()
Deprecated.
Please use
getLoggerRepository() instead. |
static Category |
getInstance(Class clazz) |
static Category |
getInstance(String name) |
Level |
getLevel() |
LoggerRepository |
getLoggerRepository()
Gets the
LoggerRepository where this Category is attached. |
String |
getName() |
Category |
getParent() |
Level |
getPriority() |
ResourceBundle |
getResourceBundle() |
static Category |
getRoot() |
void |
info(Object message) |
void |
info(Object message,
Throwable t) |
boolean |
isAttached(Appender appender)
Is the appender passed as parameter attached to this category?
|
boolean |
isDebugEnabled() |
boolean |
isEnabledFor(Priority level) |
boolean |
isErrorEnabled() |
boolean |
isFatalEnabled() |
boolean |
isInfoEnabled() |
boolean |
isWarnEnabled() |
void |
l7dlog(Priority priority,
String key,
Object[] params,
Throwable t) |
void |
l7dlog(Priority priority,
String key,
Throwable t) |
void |
log(Priority priority,
Object message) |
void |
log(Priority priority,
Object message,
Throwable t) |
void |
log(String fqcn,
Priority priority,
Object message,
Throwable t) |
void |
removeAllAppenders()
Removes all previously added appenders from this Category instance.
|
void |
removeAppender(Appender appender)
Removes the appender passed as parameter form the list of appenders.
|
void |
removeAppender(String name)
Removes the appender with the name passed as parameter form the list of appenders.
|
void |
setAdditivity(boolean additivity) |
void |
setLevel(Level level) |
void |
setPriority(Priority priority) |
void |
setResourceBundle(ResourceBundle bundle) |
static void |
shutdown()
Shuts down the current configuration.
|
void |
warn(Object message) |
void |
warn(Object message,
Throwable t) |
protected String name
protected boolean additive
false 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
to false too. See the user manual for more details.protected volatile Level level
level variable need not be assigned a value in which case it is
inherited form the hierarchy.protected volatile Category parent
protected ResourceBundle bundle
protected LoggerRepository repository
protected Category(LoggerContext context, String name)
context - The LoggerContext.name - The name of the Logger.protected Category(String name)
name - The name of the Logger.@Deprecated public static Logger exists(String name)
LogManager.exists(String) instead.name - The name to test.@Deprecated public static Enumeration getCurrentCategories()
LogManager.getCurrentLoggers() instead.Enumeration.
The root category is not included in the returned Enumeration.
@Deprecated public static LoggerRepository getDefaultHierarchy()
LogManager.getLoggerRepository() instead.public static Category getRoot()
public static void shutdown()
public void addAppender(Appender appender)
newAppender 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.
addAppender in interface AppenderAttachableappender - The Appender to add.public void assertLog(boolean assertion,
String msg)
assertion parameter is false, then logs msg as an error
statement.
The assert method has been renamed to assertLog because assert is a language
reserved word in JDK 1.4.
assertion - The assertion.msg - The message to print if assertion is false.public void callAppenders(LoggingEvent event)
this. 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.
event - the event to log.public void debug(Object message)
public void error(Object message)
public void fatal(Object message)
public boolean getAdditivity()
public Enumeration getAllAppenders()
Enumeration. Log4j 2.x appenders are omitted.getAllAppenders in interface AppenderAttachablepublic Appender getAppender(String name)
name.
Return the appender with that name if in the list. Return null otherwise.
getAppender in interface AppenderAttachablename - The name of the Appender.public Priority getChainedPriority()
public Level getEffectiveLevel()
@Deprecated public LoggerRepository getHierarchy()
getLoggerRepository() instead.LoggerRepository where this Category instance is attached.public final Level getLevel()
public LoggerRepository getLoggerRepository()
LoggerRepository where this Category is attached.public final String getName()
public final Category getParent()
public final Level getPriority()
public ResourceBundle getResourceBundle()
public void info(Object message)
public boolean isAttached(Appender appender)
isAttached in interface AppenderAttachableappender - The Appender to add.public boolean isDebugEnabled()
public boolean isEnabledFor(Priority level)
public boolean isErrorEnabled()
public boolean isFatalEnabled()
public boolean isInfoEnabled()
public boolean isWarnEnabled()
public void removeAllAppenders()
This is useful when re-reading configuration information.
removeAllAppenders in interface AppenderAttachablepublic void removeAppender(Appender appender)
removeAppender in interface AppenderAttachableappender - The Appender to remove.public void removeAppender(String name)
removeAppender in interface AppenderAttachablename - The Appender to remove.public void setAdditivity(boolean additivity)
public void setLevel(Level level)
public void setPriority(Priority priority)
public void setResourceBundle(ResourceBundle bundle)
public void warn(Object message)
Copyright © 1999-2022 The Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.