Class LoggerBase

  • All Implemented Interfaces:
    Lifecycle, Logger
    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 is log(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 Detail

      • log

        protected static final Logger log
      • container

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

        protected int debug
        The debugging detail level for this component.
      • lifecycle

        protected LifecycleSupport lifecycle
        The lifecycle event support for this component.
      • verbosity

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

      • LoggerBase

        public LoggerBase()
    • Method Detail

      • getContainer

        public Container getContainer()
        Return the Container with which this Logger has been associated.
        Specified by:
        getContainer in interface Logger
      • 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
      • 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>.
        Specified by:
        getInfo in interface Logger
      • 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
      • 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:
        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)
      • 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​(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,
                        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,
                        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
      • 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
      • 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 interface Lifecycle
        Parameters:
        listener - The listener to add
      • 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
      • 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