Package org.apache.catalina.logger
Class LoggerBase
- java.lang.Object
-
- org.apache.catalina.logger.LoggerBase
-
- Direct Known Subclasses:
FileLogger
,SystemErrLogger
,SystemOutLogger
public class LoggerBase extends Object implements Lifecycle, Logger
Convenience base class for Logger implementations. The only method that must be implemented islog(String msg)
, plus any property setting and lifecycle methods required for configuration.- Version:
- $Revision: 1.4 $ $Date: 2006/10/07 01:14:23 $
- Author:
- Craig R. McClanahan
-
-
Field Summary
Fields Modifier and Type Field Description 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 static String
info
The descriptive information about this implementation.protected LifecycleSupport
lifecycle
The lifecycle event support for this component.protected static Logger
log
protected ObjectName
oname
protected static ResourceBundle
rb
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, INIT_EVENT, START_EVENT, STOP_EVENT
-
-
Constructor Summary
Constructors Constructor Description LoggerBase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addHandler(Handler handler)
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()
List<LifecycleListener>
findLifecycleListeners()
Gets the (possibly empty) list of lifecycle listeners associated with this LoggerBase.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
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 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
log(String msg, Throwable throwable)
Writes an explanatory message and a stack trace for a givenThrowable
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
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
setLevel(String logLevel)
Set the verbosity level of this logger.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 Detail
-
log
protected static final Logger log
-
rb
protected static final ResourceBundle rb
-
container
protected Container container
The Container with which this Logger has been associated.
-
debug
protected int debug
The debugging detail level for this component.
-
info
protected static final String info
The descriptive information about this implementation.- See Also:
- Constant Field Values
-
lifecycle
protected LifecycleSupport lifecycle
The lifecycle event support for this component.
-
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.
-
oname
protected ObjectName oname
-
controller
protected ObjectName controller
-
-
Method Detail
-
getContainer
public Container getContainer()
Return the Container with which this Logger has been associated.- Specified by:
getContainer
in interfaceLogger
-
setContainer
public void setContainer(Container container)
Set the Container with which this Logger has been associated.- Specified by:
setContainer
in interfaceLogger
- Parameters:
container
- The associated Container
-
getDebug
public int getDebug()
Return the debugging detail level for this component.
-
setDebug
public void setDebug(int debug)
Set the debugging detail level for this component.- Parameters:
debug
- The new debugging detail level
-
getInfo
public String getInfo()
Return descriptive information about this Logger implementation and the corresponding version number, in the format<description>/<version>
.
-
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 interfaceLogger
-
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 interfaceLogger
- 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:
verbosityLevel
- The new verbosity level, as a string
-
setLevel
public void setLevel(String logLevel)
Set the verbosity level of this logger. Messages logged with a higher verbosity than this level will be silently ignored.- Parameters:
verbosityLevel
- The new verbosity level, as a string
-
addHandler
public void addHandler(Handler handler)
-
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener listener)
Add a property change listener to this component.- Specified by:
addPropertyChangeListener
in interfaceLogger
- Parameters:
listener
- The listener to add
-
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.
-
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 calllog(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.
-
log
public void log(String msg, Throwable throwable)
Writes an explanatory message and a stack trace for a givenThrowable
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.
-
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.
-
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.
-
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener listener)
Remove a property change listener from this component.- Specified by:
removePropertyChangeListener
in interfaceLogger
- Parameters:
listener
- The listener to remove
-
getController
public ObjectName getController()
-
setController
public void setController(ObjectName controller)
-
getObjectName
public ObjectName getObjectName()
-
init
public void init()
-
destroy
public void destroy()
-
createObjectName
public ObjectName createObjectName()
-
addLifecycleListener
public void addLifecycleListener(LifecycleListener listener)
Add a lifecycle event listener to this component.- Specified by:
addLifecycleListener
in interfaceLifecycle
- Parameters:
listener
- The listener to add
-
findLifecycleListeners
public List<LifecycleListener> findLifecycleListeners()
Gets the (possibly empty) list of lifecycle listeners associated with this LoggerBase.- Specified by:
findLifecycleListeners
in interfaceLifecycle
-
removeLifecycleListener
public void removeLifecycleListener(LifecycleListener listener)
Remove a lifecycle event listener from this component.- Specified by:
removeLifecycleListener
in interfaceLifecycle
- Parameters:
listener
- The listener to add
-
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 afterconfigure()
, and before any of the public methods of the component are utilized.- Specified by:
start
in interfaceLifecycle
- 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 interfaceLifecycle
- Throws:
LifecycleException
- if this component detects a fatal error that needs to be reported
-
-