org.apache.catalina.logger

Class LoggerBase

Implemented Interfaces:
Lifecycle, Logger, MBeanRegistration
Known Direct Subclasses:
FileLogger, SystemErrLogger, SystemOutLogger

public class LoggerBase
extends java.lang.Object
implements Lifecycle, Logger, MBeanRegistration

Convenience base class for Logger implementations. The only method that must be implemented is log(String msg), plus any property setting and lifecycle methods required for configuration.

Version:
$Revision: 1.9 $ $Date: 2004/05/26 15:48:29 $

Author:
Craig R. McClanahan

Field Summary

protected Container
container
The Container with which this Logger has been associated.
protected ObjectName
controller
protected int
debug
The debugging detail level for this component.
protected String
domain
protected String
host
protected static String
info
The descriptive information about this implementation.
protected LifecycleSupport
lifecycle
The lifecycle event support for this component.
protected MBeanServer
mserver
protected ObjectName
oname
protected String
path
protected PropertyChangeSupport
support
The property change support for this component.
protected int
verbosity
The verbosity level for above which log messages may be filtered.

Fields inherited from interface org.apache.catalina.Lifecycle

AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, START_EVENT, STOP_EVENT

Fields inherited from interface org.apache.catalina.Logger

DEBUG, ERROR, FATAL, INFORMATION, WARNING

Method Summary

void
addLifecycleListener(LifecycleListener listener)
Add a lifecycle event listener to this component.
void
addPropertyChangeListener(PropertyChangeListener listener)
Add a property change listener to this component.
ObjectName
createObjectName()
void
destroy()
LifecycleListener[]
findLifecycleListeners()
Get the lifecycle listeners associated with this lifecycle.
Container
getContainer()
Return the Container with which this Logger has been associated.
ObjectName
getController()
int
getDebug()
Return the debugging detail level for this component.
String
getDomain()
String
getInfo()
Return descriptive information about this Logger implementation and the corresponding version number, in the format <description>/<version>.
ObjectName
getObjectName()
int
getVerbosity()
Return the verbosity level of this logger.
void
init()
void
log(Exception exception, String msg)
Writes the specified exception, and message, to a servlet log file.
void
log(String msg)
Writes the specified message to a servlet log file, usually an event log.
void
log(String msg, Throwable throwable)
Writes an explanatory message and a stack trace for a given Throwable exception to the servlet log file.
void
log(String message, Throwable throwable, int verbosity)
Writes the specified message and exception to the servlet log file, usually an event log, if the logger is set to a verbosity level equal to or higher than the specified value for this message.
void
log(String message, int verbosity)
Writes the specified message to the servlet log file, usually an event log, if the logger is set to a verbosity level equal to or higher than the specified value for this message.
void
postDeregister()
void
postRegister(Boolean registrationDone)
void
preDeregister()
ObjectName
preRegister(MBeanServer server, ObjectName name)
void
removeLifecycleListener(LifecycleListener listener)
Remove a lifecycle event listener from this component.
void
removePropertyChangeListener(PropertyChangeListener listener)
Remove a property change listener from this component.
void
setContainer(Container container)
Set the Container with which this Logger has been associated.
void
setController(ObjectName controller)
void
setDebug(int debug)
Set the debugging detail level for this component.
void
setVerbosity(int verbosity)
Set the verbosity level of this logger.
void
setVerbosityLevel(String verbosity)
Set the verbosity level of this logger.
void
start()
Prepare for the beginning of active use of the public methods of this component.
void
stop()
Gracefully terminate the active use of the public methods of this component.

Field Details

container

protected Container container
The Container with which this Logger has been associated.


controller

protected ObjectName controller


debug

protected int debug
The debugging detail level for this component.


domain

protected String domain


host

protected String host


info

protected static final String info
The descriptive information about this implementation.


lifecycle

protected LifecycleSupport lifecycle
The lifecycle event support for this component.


mserver

protected MBeanServer mserver


oname

protected ObjectName oname


path

protected String path


support

protected PropertyChangeSupport support
The property change support for this component.


verbosity

protected int verbosity
The verbosity level for above which log messages may be filtered.

Method Details

addLifecycleListener

public void addLifecycleListener(LifecycleListener listener)
Add a lifecycle event listener to this component.
Specified by:
addLifecycleListener in interface Lifecycle

Parameters:
listener - The listener to add


addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Add a property change listener to this component.
Specified by:
addPropertyChangeListener in interface Logger

Parameters:
listener - The listener to add


createObjectName

public ObjectName createObjectName()


destroy

public void destroy()


findLifecycleListeners

public LifecycleListener[] findLifecycleListeners()
Get the lifecycle listeners associated with this lifecycle. If this Lifecycle has no listeners registered, a zero-length array is returned.
Specified by:
findLifecycleListeners in interface Lifecycle


getContainer

public Container getContainer()
Return the Container with which this Logger has been associated.
Specified by:
getContainer in interface Logger


getController

public ObjectName getController()


getDebug

public int getDebug()
Return the debugging detail level for this component.


getDomain

public String getDomain()


getInfo

public String getInfo()
Return descriptive information about this Logger implementation and the corresponding version number, in the format <description>/<version>.
Specified by:
getInfo in interface Logger


getObjectName

public ObjectName getObjectName()


getVerbosity

public int getVerbosity()
Return the verbosity level of this logger. Messages logged with a higher verbosity than this level will be silently ignored.
Specified by:
getVerbosity in interface Logger


init

public void init()


log

public void log(Exception exception,
                String msg)
Writes the specified exception, and message, to a servlet log file. The implementation of this method should call log(msg, exception) instead. This method is deprecated in the ServletContext interface, but not deprecated here to avoid many useless compiler warnings. This message will be logged unconditionally.
Specified by:
log in interface Logger

Parameters:
exception - An Exception to be reported
msg - The associated message string


log

public void log(String msg)
Writes the specified message to a servlet log file, usually an event log. The name and type of the servlet log is specific to the servlet container. This message will be logged unconditionally.
Specified by:
log in interface Logger

Parameters:
msg - A String specifying the message to be written to the log file


log

public void log(String msg,
                Throwable throwable)
Writes an explanatory message and a stack trace for a given Throwable exception to the servlet log file. The name and type of the servlet log file is specific to the servlet container, usually an event log. This message will be logged unconditionally.
Specified by:
log in interface Logger

Parameters:
msg - A String that describes the error or exception
throwable - The Throwable error or exception


log

public void log(String message,
                Throwable throwable,
                int verbosity)
Writes the specified message and exception to the servlet log file, usually an event log, if the logger is set to a verbosity level equal to or higher than the specified value for this message.
Specified by:
log in interface Logger

Parameters:
message - A String that describes the error or exception
throwable - The Throwable error or exception
verbosity - Verbosity level of this message


log

public void log(String message,
                int verbosity)
Writes the specified message to the servlet log file, usually an event log, if the logger is set to a verbosity level equal to or higher than the specified value for this message.
Specified by:
log in interface Logger

Parameters:
message - A String specifying the message to be written to the log file
verbosity - Verbosity level of this message


postDeregister

public void postDeregister()


postRegister

public void postRegister(Boolean registrationDone)


preDeregister

public void preDeregister()
            throws Exception


preRegister

public ObjectName preRegister(MBeanServer server,
                              ObjectName name)
            throws Exception


removeLifecycleListener

public void removeLifecycleListener(LifecycleListener listener)
Remove a lifecycle event listener from this component.
Specified by:
removeLifecycleListener in interface Lifecycle

Parameters:
listener - The listener to add


removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Remove a property change listener from this component.
Specified by:
removePropertyChangeListener in interface Logger

Parameters:
listener - The listener to remove


setContainer

public void setContainer(Container container)
Set the Container with which this Logger has been associated.
Specified by:
setContainer in interface Logger

Parameters:
container - The associated Container


setController

public void setController(ObjectName controller)


setDebug

public void setDebug(int debug)
Set the debugging detail level for this component.

Parameters:
debug - The new debugging detail level


setVerbosity

public void setVerbosity(int verbosity)
Set the verbosity level of this logger. Messages logged with a higher verbosity than this level will be silently ignored.
Specified by:
setVerbosity in interface Logger

Parameters:
verbosity - The new verbosity level


setVerbosityLevel

public void setVerbosityLevel(String verbosity)
Set the verbosity level of this logger. Messages logged with a higher verbosity than this level will be silently ignored.

Parameters:
verbosity - The new verbosity level, as a string


start

public void start()
            throws LifecycleException
Prepare for the beginning of active use of the public methods of this component. This method should be called after configure(), and before any of the public methods of the component are utilized.
Specified by:
start in interface Lifecycle

Throws:
LifecycleException - if this component detects a fatal error that prevents this component from being used


stop

public void stop()
            throws LifecycleException
Gracefully terminate the active use of the public methods of this component. This method should be the last one called on a given instance of this component.
Specified by:
stop in interface Lifecycle

Throws:
LifecycleException - if this component detects a fatal error that needs to be reported


Copyright B) 2000-2003 Apache Software Foundation. All Rights Reserved.