Top Description Fields Constructors Methods
org.apache.log

public Class Logger

extends Object
Class Inheritance
Imports
org.apache.log.util.LoggerListener

The object interacted with by client objects to perform logging.
Authors
Avalon Development Team, Peter Donald

Field Summary

Modifier and TypeField and Description
public static final char
CATEGORY_SEPARATOR

Separator character use to separate different categories

private static final Logger[]
private boolean
m_additivity

True means LogEvents will be sent to parents LogTargets aswell as the ones set for this Logger.

private final String
private Logger[]
private final ErrorHandler
private final LoggerListener
private LogTarget[]
private boolean
private final Logger
private Priority
private boolean

Constructor Summary

AccessConstructor and Description
pack-priv
Logger(final ErrorHandler
the ErrorHandler logger uses to log errors
errorHandler
,
final LoggerListener loggerListener, final String
the fully qualified name of category
category
,
final LogTarget[]
the LogTargets associated with logger
logTargets
,
final Logger
the parent logger (used for inheriting from)
parent
)

Protected constructor for use inside the logging toolkit.

Method Summary

Modifier and TypeMethod and Description
public final void
debug(final String
the message
message
,
final Throwable
the throwable
throwable
)

Log a debug priority event.

public final void
debug(final String
the message
message
)

Log a debug priority event.

public final void
error(final String
the message
message
,
final Throwable
the throwable
throwable
)

Log a error priority event.

public final void
error(final String
the message
message
)

Log a error priority event.

public final void
fatalError(final String
the message
message
,
final Throwable
the throwable
throwable
)

Log a fatalError priority event.

public final void
fatalError(final String
the message
message
)

Log a fatalError priority event.

private final void
fireEvent(final LogEvent event, final LogTarget[] targets)

public synchronized Logger

Returns:

the new logger
getChildLogger
(final String
the subcategory of this logger
subCategory
)

Create a new child logger.

public synchronized Logger[]

Returns:

the child loggers
getChildren
()

Get all the child Loggers of current logger.

public final void
info(final String
the message
message
,
final Throwable
the throwable
throwable
)

Log a info priority event.

public final void
info(final String
the message
message
)

Log a info priority event.

public final boolean

Returns:

true if DEBUG messages will be logged
isDebugEnabled
()

Determine if messages of priority DEBUG will be logged.

public final boolean

Returns:

true if ERROR messages will be logged
isErrorEnabled
()

Determine if messages of priority ERROR will be logged.

public final boolean

Returns:

true if FATAL_ERROR messages will be logged
isFatalErrorEnabled
()

Determine if messages of priority FATAL_ERROR will be logged.

public final boolean

Returns:

true if INFO messages will be logged
isInfoEnabled
()

Determine if messages of priority INFO will be logged.

public final boolean

Returns:

true if messages will be logged
isPriorityEnabled
(final Priority
the priority
priority
)

Determine if messages of priority �will be logged.

public final boolean

Returns:

true if WARN messages will be logged
isWarnEnabled
()

Determine if messages of priority WARN will be logged.

public final void
log(final Priority
the priority
priority
,
final String
the message
message
,
final Throwable
the throwable
throwable
)

Log a event at specific priority with a certain message and throwable.

public final void
log(final Priority
the priority
priority
,
final String
the message
message
)

Log a event at specific priority with a certain message.

private final void
output(final Priority
the priority
priority
,
final String
the message
message
,
final Throwable
the throwable
throwable
)

Internal method to do actual outputting.

private final void
output(final LogEvent event)

private synchronized void
resetChildLogTargets(final boolean recursive)

Update logTargets of children if any.

private synchronized void
resetChildPriorities(final boolean recursive)

Update priority of children if any.

private synchronized void
resetLogTargets(final boolean recursive)

Update logTarget of this Logger.

private synchronized void
resetPriority(final boolean recursive)

Update priority of this Logger.

private synchronized LogTarget[]

Returns:

the array of LogTargets
safeGetLogTargets
()

Retrieve logtarget array contained in logger.

public final void
setAdditivity(final boolean
true to make logger additive, false otherwise
additivity
)

Make this logger additive.

public synchronized void
setLogTargets(final LogTarget[]
the Log Targets
logTargets
)

Set the log targets for this logger.

public synchronized void
setPriority(final Priority
the priority
priority
)

Set the priority for this logger.

private synchronized void
setupErrorHandlers()

Set ErrorHandlers of LogTargets if necessary.

public synchronized void
unsetLogTargets()

Unset the logtargets for this logger.

public synchronized void
unsetLogTargets(final boolean
the recursion policy
recursive
)

Unset the logtargets for this logger and all child loggers if recursive is set.

public synchronized void
unsetPriority()

Unset the priority of Logger.

public synchronized void
unsetPriority(final boolean
true to unset priority of all child loggers
recursive
)

Unset the priority of Logger.

public final void
warn(final String
the message
message
,
final Throwable
the throwable
throwable
)

Log a warn priority event.

public final void
warn(final String
the message
message
)

Log a warn priority event.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CATEGORY_SEPARATORback to summary
public static final char CATEGORY_SEPARATOR

Separator character use to separate different categories

EMPTY_SETback to summary
private static final Logger[] EMPTY_SET
m_additivityback to summary
private boolean m_additivity

True means LogEvents will be sent to parents LogTargets aswell as the ones set for this Logger.

m_categoryback to summary
private final String m_category
m_childrenback to summary
private Logger[] m_children
m_errorHandlerback to summary
private final ErrorHandler m_errorHandler
m_loggerListenerback to summary
private final LoggerListener m_loggerListener
m_logTargetsback to summary
private LogTarget[] m_logTargets
m_logTargetsForceSetback to summary
private boolean m_logTargetsForceSet
m_parentback to summary
private final Logger m_parent
m_priorityback to summary
private Priority m_priority
m_priorityForceSetback to summary
private boolean m_priorityForceSet

Constructor Detail

Loggerback to summary
pack-priv Logger(final ErrorHandler errorHandler, final LoggerListener loggerListener, final String category, final LogTarget[] logTargets, final Logger parent)

Protected constructor for use inside the logging toolkit. You should not be using this constructor directly.

Parameters
errorHandler:ErrorHandler

the ErrorHandler logger uses to log errors

category:String

the fully qualified name of category

logTargets:LogTarget[]

the LogTargets associated with logger

parent:Logger

the parent logger (used for inheriting from)

Method Detail

debugback to summary
public final void debug(final String message, final Throwable throwable)

Log a debug priority event.

Parameters
message:String

the message

throwable:Throwable

the throwable

debugback to summary
public final void debug(final String message)

Log a debug priority event.

Parameters
message:String

the message

errorback to summary
public final void error(final String message, final Throwable throwable)

Log a error priority event.

Parameters
message:String

the message

throwable:Throwable

the throwable

errorback to summary
public final void error(final String message)

Log a error priority event.

Parameters
message:String

the message

fatalErrorback to summary
public final void fatalError(final String message, final Throwable throwable)

Log a fatalError priority event.

Parameters
message:String

the message

throwable:Throwable

the throwable

fatalErrorback to summary
public final void fatalError(final String message)

Log a fatalError priority event.

Parameters
message:String

the message

fireEventback to summary
private final void fireEvent(final LogEvent event, final LogTarget[] targets)
getChildLoggerback to summary
public synchronized Logger getChildLogger(final String subCategory) throws IllegalArgumentException

Create a new child logger. The category of child logger is [current-category].subcategory

Parameters
subCategory:String

the subcategory of this logger

Returns:Logger

the new logger

Exceptions
IllegalArgumentException:
if subCategory has an empty element name
getChildrenback to summary
public synchronized Logger[] getChildren()

Get all the child Loggers of current logger.

Returns:Logger[]

the child loggers

infoback to summary
public final void info(final String message, final Throwable throwable)

Log a info priority event.

Parameters
message:String

the message

throwable:Throwable

the throwable

infoback to summary
public final void info(final String message)

Log a info priority event.

Parameters
message:String

the message

isDebugEnabledback to summary
public final boolean isDebugEnabled()

Determine if messages of priority DEBUG will be logged.

Returns:boolean

true if DEBUG messages will be logged

isErrorEnabledback to summary
public final boolean isErrorEnabled()

Determine if messages of priority ERROR will be logged.

Returns:boolean

true if ERROR messages will be logged

isFatalErrorEnabledback to summary
public final boolean isFatalErrorEnabled()

Determine if messages of priority FATAL_ERROR will be logged.

Returns:boolean

true if FATAL_ERROR messages will be logged

isInfoEnabledback to summary
public final boolean isInfoEnabled()

Determine if messages of priority INFO will be logged.

Returns:boolean

true if INFO messages will be logged

isPriorityEnabledback to summary
public final boolean isPriorityEnabled(final Priority priority)

Determine if messages of priority �will be logged.

Parameters
priority:Priority

the priority

Returns:boolean

true if messages will be logged

isWarnEnabledback to summary
public final boolean isWarnEnabled()

Determine if messages of priority WARN will be logged.

Returns:boolean

true if WARN messages will be logged

logback to summary
public final void log(final Priority priority, final String message, final Throwable throwable)

Log a event at specific priority with a certain message and throwable.

Parameters
priority:Priority

the priority

message:String

the message

throwable:Throwable

the throwable

logback to summary
public final void log(final Priority priority, final String message)

Log a event at specific priority with a certain message.

Parameters
priority:Priority

the priority

message:String

the message

outputback to summary
private final void output(final Priority priority, final String message, final Throwable throwable)

Internal method to do actual outputting.

Parameters
priority:Priority

the priority

message:String

the message

throwable:Throwable

the throwable

outputback to summary
private final void output(final LogEvent event)
resetChildLogTargetsback to summary
private synchronized void resetChildLogTargets(final boolean recursive)

Update logTargets of children if any.

resetChildPrioritiesback to summary
private synchronized void resetChildPriorities(final boolean recursive)

Update priority of children if any.

resetLogTargetsback to summary
private synchronized void resetLogTargets(final 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.

resetPriorityback to summary
private synchronized void resetPriority(final 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.

safeGetLogTargetsback to summary
private synchronized LogTarget[] safeGetLogTargets()

Retrieve logtarget array contained in logger. This method is provided so that child Loggers can access a copy of parents LogTargets.

Returns:LogTarget[]

the array of LogTargets

setAdditivityback to summary
public final void setAdditivity(final 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:boolean

true to make logger additive, false otherwise

setLogTargetsback to summary
public synchronized void setLogTargets(final LogTarget[] logTargets)

Set the log targets for this logger.

Parameters
logTargets:LogTarget[]

the Log Targets

setPriorityback to summary
public synchronized void setPriority(final Priority priority)

Set the priority for this logger.

Parameters
priority:Priority

the priority

setupErrorHandlersback to summary
private synchronized void setupErrorHandlers()

Set ErrorHandlers of LogTargets if necessary.

unsetLogTargetsback to summary
public synchronized 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.

unsetLogTargetsback to summary
public synchronized void unsetLogTargets(final 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:boolean

the recursion policy

unsetPriorityback to summary
public synchronized void unsetPriority()

Unset the priority of Logger. (Thus it will use it's parent's priority or DEBUG if no parent.

unsetPriorityback to summary
public synchronized void unsetPriority(final 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:boolean

true to unset priority of all child loggers

warnback to summary
public final void warn(final String message, final Throwable throwable)

Log a warn priority event.

Parameters
message:String

the message

throwable:Throwable

the throwable

warnback to summary
public final void warn(final String message)

Log a warn priority event.

Parameters
message:String

the message