Class CatalinaLogger

  • All Implemented Interfaces:
    Logger

    public final class CatalinaLogger
    extends Object
    This is an adapter of java.util.logging.Logger to org.apache.catalina.Logger.
    Author:
    Shing Wai Chan
    • Constructor Summary

      Constructors 
      Constructor Description
      CatalinaLogger​(Logger logger)
      Construct a new instance of this class, that uses the specified logger instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addPropertyChangeListener​(PropertyChangeListener listener)
      Add a property change listener to this component.
      Container getContainer()
      Return the Container with which this Logger has been associated.
      String getInfo()
      Return descriptive information about this Logger implementation and the corresponding version number, in the format <description>/<version>.
      int getVerbosity()
      Logger interface method (ignored)
      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 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 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 setLevel​(String logLevel)
      Set the verbosity level of this logger.
      void setVerbosity​(int verbosity)
      Logger interface method (ignored)
      protected void write​(String msg, int verbosity)
      Logs the given message at the given verbosity level.
      protected void write​(String msg, Throwable throwable, int verbosity)  
    • Field Detail

      • container

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

      • CatalinaLogger

        public CatalinaLogger​(Logger logger)
        Construct a new instance of this class, that uses the specified logger instance.
        Parameters:
        logger - The logger to send log messages to
    • Method Detail

      • write

        protected void write​(String msg,
                             int verbosity)
        Logs the given message at the given verbosity level.
      • 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:
        logLevel - The new verbosity level, as a string
      • 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
      • 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()
        Logger interface method (ignored)
        Specified by:
        getVerbosity in interface Logger
      • setVerbosity

        public void setVerbosity​(int verbosity)
        Logger interface method (ignored)
        Specified by:
        setVerbosity in interface Logger
        Parameters:
        verbosity - The new verbosity level
      • 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.
        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
      • write

        protected void write​(String msg,
                             Throwable throwable,
                             int verbosity)