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 ContainercontainerThe Container with which this Logger has been associated.protected ObjectNamecontrollerprotected intdebugThe debugging detail level for this component.protected static StringinfoThe descriptive information about this implementation.protected LifecycleSupportlifecycleThe lifecycle event support for this component.protected static Loggerlogprotected ObjectNameonameprotected static ResourceBundlerbprotected PropertyChangeSupportsupportThe property change support for this component.protected intverbosityThe 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 voidaddHandler(Handler handler)voidaddLifecycleListener(LifecycleListener listener)Add a lifecycle event listener to this component.voidaddPropertyChangeListener(PropertyChangeListener listener)Add a property change listener to this component.ObjectNamecreateObjectName()voiddestroy()List<LifecycleListener>findLifecycleListeners()Gets the (possibly empty) list of lifecycle listeners associated with this LoggerBase.ContainergetContainer()Return the Container with which this Logger has been associated.ObjectNamegetController()intgetDebug()Return the debugging detail level for this component.StringgetInfo()Return descriptive information about this Logger implementation and the corresponding version number, in the format<description>/<version>.ObjectNamegetObjectName()intgetVerbosity()Return the verbosity level of this logger.voidinit()voidlog(Exception exception, String msg)Writes the specified exception, and message, to a servlet log file.voidlog(String msg)Writes the specified message to a servlet log file, usually an event log.voidlog(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.voidlog(String msg, Throwable throwable)Writes an explanatory message and a stack trace for a givenThrowableexception to the servlet log file.voidlog(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.voidremoveLifecycleListener(LifecycleListener listener)Remove a lifecycle event listener from this component.voidremovePropertyChangeListener(PropertyChangeListener listener)Remove a property change listener from this component.voidsetContainer(Container container)Set the Container with which this Logger has been associated.voidsetController(ObjectName controller)voidsetDebug(int debug)Set the debugging detail level for this component.voidsetLevel(String logLevel)Set the verbosity level of this logger.voidsetVerbosity(int verbosity)Set the verbosity level of this logger.voidsetVerbosityLevel(String verbosity)Set the verbosity level of this logger.voidstart()Prepare for the beginning of active use of the public methods of this component.voidstop()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:
getContainerin interfaceLogger
-
setContainer
public void setContainer(Container container)
Set the Container with which this Logger has been associated.- Specified by:
setContainerin 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:
getVerbosityin 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:
setVerbosityin 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:
addPropertyChangeListenerin 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 givenThrowableexception 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:
removePropertyChangeListenerin 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:
addLifecycleListenerin 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:
findLifecycleListenersin interfaceLifecycle
-
removeLifecycleListener
public void removeLifecycleListener(LifecycleListener listener)
Remove a lifecycle event listener from this component.- Specified by:
removeLifecycleListenerin interfaceLifecycle- Parameters:
listener- The listener to add
-
start
public void start() throws LifecycleExceptionPrepare 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:
startin interfaceLifecycle- Throws:
LifecycleException- if this component detects a fatal error that prevents this component from being used
-
stop
public void stop() throws LifecycleExceptionGracefully 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:
stopin interfaceLifecycle- Throws:
LifecycleException- if this component detects a fatal error that needs to be reported
-
-