Class Logger
java.lang.Object
org.apache.log.Logger
The object interacted with by client objects to perform logging.
- Author:
- Avalon Development Team, Peter Donald
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final charSeparator character use to separate different categoriesprivate static final Logger[]private booleanTrue means LogEvents will be sent to parents LogTargets aswell as the ones set for this Logger.private final Stringthe fully qualified name of categoryprivate Logger[]The list of child loggers associated with this loggerprivate final ErrorHandlerprivate final LoggerListenerThe ErrorHandler associated with Loggerprivate LogTarget[]The log-targets this logger writes toprivate booleanIndicate that logTargets were set with setLogTargets() rather than inheritedprivate final LoggerLogger to inherit logtargets and priorities fromprivate PriorityThe priority threshold associated with loggerprivate booleanIndicate that priority was set with setPriority() rather than inherited -
Constructor Summary
ConstructorsConstructorDescriptionLogger(ErrorHandler errorHandler, LoggerListener loggerListener, String category, LogTarget[] logTargets, Logger parent) Protected constructor for use inside the logging toolkit. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidLog a debug priority event.final voidLog a debug priority event.final voidLog a error priority event.final voidLog a error priority event.final voidfatalError(String message) Log a fatalError priority event.final voidfatalError(String message, Throwable throwable) Log a fatalError priority event.private final voidgetChildLogger(String subCategory) Create a new child logger.Logger[]Get all the child Loggers of current logger.final voidLog a info priority event.final voidLog a info priority event.final booleanDetermine if messages of priority DEBUG will be logged.final booleanDetermine if messages of priority ERROR will be logged.final booleanDetermine if messages of priority FATAL_ERROR will be logged.final booleanDetermine if messages of priority INFO will be logged.final booleanisPriorityEnabled(Priority priority) Determine if messages of priority will be logged.final booleanDetermine if messages of priority WARN will be logged.final voidLog a event at specific priority with a certain message.final voidLog a event at specific priority with a certain message and throwable.private final voidprivate final voidInternal method to do actual outputting.private voidresetChildLogTargets(boolean recursive) Update logTargets of children if any.private voidresetChildPriorities(boolean recursive) Update priority of children if any.private voidresetLogTargets(boolean recursive) Update logTarget of this Logger.private voidresetPriority(boolean recursive) Update priority of this Logger.private LogTarget[]Retrieve logtarget array contained in logger.final voidsetAdditivity(boolean additivity) Make this logger additive.voidsetLogTargets(LogTarget[] logTargets) Set the log targets for this logger.voidsetPriority(Priority priority) Set the priority for this logger.private voidSet ErrorHandlers of LogTargets if necessary.voidUnset the logtargets for this logger.voidunsetLogTargets(boolean recursive) Unset the logtargets for this logger and all child loggers if recursive is set.voidUnset the priority of Logger.voidunsetPriority(boolean recursive) Unset the priority of Logger.final voidLog a warn priority event.final voidLog a warn priority event.
-
Field Details
-
EMPTY_SET
-
CATEGORY_SEPARATOR
public static final char CATEGORY_SEPARATORSeparator character use to separate different categories- See Also:
-
m_errorHandler
-
m_loggerListener
The ErrorHandler associated with Logger -
m_parent
Logger to inherit logtargets and priorities from -
m_category
the fully qualified name of category -
m_children
The list of child loggers associated with this logger -
m_logTargets
The log-targets this logger writes to -
m_logTargetsForceSet
private boolean m_logTargetsForceSetIndicate that logTargets were set with setLogTargets() rather than inherited -
m_priority
The priority threshold associated with logger -
m_priorityForceSet
private boolean m_priorityForceSetIndicate that priority was set with setPriority() rather than inherited -
m_additivity
private boolean m_additivityTrue means LogEvents will be sent to parents LogTargets aswell as the ones set for this Logger.
-
-
Constructor Details
-
Logger
Logger(ErrorHandler errorHandler, LoggerListener loggerListener, String category, LogTarget[] logTargets, Logger parent) Protected constructor for use inside the logging toolkit. You should not be using this constructor directly.- Parameters:
errorHandler- the ErrorHandler logger uses to log errorscategory- the fully qualified name of categorylogTargets- the LogTargets associated with loggerparent- the parent logger (used for inheriting from)
-
-
Method Details
-
isDebugEnabled
public final boolean isDebugEnabled()Determine if messages of priority DEBUG will be logged.- Returns:
- true if DEBUG messages will be logged
-
debug
-
debug
Log a debug priority event.- Parameters:
message- the message
-
isInfoEnabled
public final boolean isInfoEnabled()Determine if messages of priority INFO will be logged.- Returns:
- true if INFO messages will be logged
-
info
-
info
-
isWarnEnabled
public final boolean isWarnEnabled()Determine if messages of priority WARN will be logged.- Returns:
- true if WARN messages will be logged
-
warn
-
warn
-
isErrorEnabled
public final boolean isErrorEnabled()Determine if messages of priority ERROR will be logged.- Returns:
- true if ERROR messages will be logged
-
error
-
error
Log a error priority event.- Parameters:
message- the message
-
isFatalErrorEnabled
public final boolean isFatalErrorEnabled()Determine if messages of priority FATAL_ERROR will be logged.- Returns:
- true if FATAL_ERROR messages will be logged
-
fatalError
-
fatalError
Log a fatalError priority event.- Parameters:
message- the message
-
setAdditivity
public final void setAdditivity(boolean additivity) Make this logger additive. I.e. Send all log events to parent loggers LogTargets regardless of whether or not the LogTargets have been overidden. This is derived from Log4js notion of Additivity.- Parameters:
additivity- true to make logger additive, false otherwise
-
isPriorityEnabled
Determine if messages of priority will be logged.- Parameters:
priority- the priority- Returns:
- true if messages will be logged
-
log
-
log
-
setPriority
Set the priority for this logger.- Parameters:
priority- the priority
-
unsetPriority
public void unsetPriority()Unset the priority of Logger. (Thus it will use it's parent's priority or DEBUG if no parent. -
unsetPriority
public void unsetPriority(boolean recursive) Unset the priority of Logger. (Thus it will use it's parent's priority or DEBUG if no parent. If recursive is true unset priorities of all child loggers.- Parameters:
recursive- true to unset priority of all child loggers
-
setLogTargets
Set the log targets for this logger.- Parameters:
logTargets- the Log Targets
-
unsetLogTargets
public void unsetLogTargets()Unset the logtargets for this logger. This logger (and thus all child loggers who don't specify logtargets) will inherit from the parents LogTargets. -
unsetLogTargets
public void unsetLogTargets(boolean recursive) Unset the logtargets for this logger and all child loggers if recursive is set. The loggers unset (and all child loggers who don't specify logtargets) will inherit from the parents LogTargets.- Parameters:
recursive- the recursion policy
-
getChildren
Get all the child Loggers of current logger.- Returns:
- the child loggers
-
getChildLogger
Create a new child logger. The category of child logger is [current-category].subcategory- Parameters:
subCategory- the subcategory of this logger- Returns:
- the new logger
- Throws:
IllegalArgumentException- if subCategory has an empty element name
-
output
-
output
-
fireEvent
-
resetChildPriorities
private void resetChildPriorities(boolean recursive) Update priority of children if any. -
resetPriority
private void resetPriority(boolean recursive) Update priority of this Logger. If this loggers priority was manually set then ignore otherwise get parents priority and update all children's priority. -
safeGetLogTargets
Retrieve logtarget array contained in logger. This method is provided so that child Loggers can access a copy of parents LogTargets.- Returns:
- the array of LogTargets
-
resetChildLogTargets
private void resetChildLogTargets(boolean recursive) Update logTargets of children if any. -
setupErrorHandlers
private void setupErrorHandlers()Set ErrorHandlers of LogTargets if necessary. -
resetLogTargets
private void resetLogTargets(boolean recursive) Update logTarget of this Logger. If this loggers logTarget was manually set then ignore otherwise get parents logTarget and update all children's logTarget.
-