Class ServletLogChute

  • All Implemented Interfaces:
    LogChute

    public class ServletLogChute
    extends java.lang.Object
    implements LogChute
    Simple wrapper for the servlet log. This passes Velocity log messages to ServletContext.log(String). You may configure the level of output in your velocity.properties by adding the "runtime.log.logsystem.servlet.level" property with one of the following values: error, warn, info, debug, or trace. The default is trace.
    Since:
    1.6
    Version:
    $Revision: 730039 $ $Date: 2008-12-30 04:53:19 +0100 (Tue, 30 Dec 2008) $
    Author:
    Geir Magnusson Jr., Nathan Bubna
    • Constructor Summary

      Constructors 
      Constructor Description
      ServletLogChute()
      Construct a simple logger for a servlet environment.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getEnabledLevel()
      Returns the current minimum level at which messages will be printed.
      void init​(RuntimeServices rs)
      init()
      boolean isLevelEnabled​(int level)
      This will return true if the specified level is equal to or higher than the level this LogChute is enabled for.
      void log​(int level, java.lang.String message)
      Send a log message from Velocity.
      void log​(int level, java.lang.String message, java.lang.Throwable t)
      Send a log message from Velocity along with an exception or error
      void setEnabledLevel​(int level)
      Set the minimum level at which messages will be printed.
      protected int toLevel​(java.lang.String level)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • RUNTIME_LOG_LEVEL_KEY

        public static final java.lang.String RUNTIME_LOG_LEVEL_KEY
        See Also:
        Constant Field Values
      • servletContext

        protected javax.servlet.ServletContext servletContext
    • Constructor Detail

      • ServletLogChute

        public ServletLogChute()
        Construct a simple logger for a servlet environment.
        NOTE: this class expects that the ServletContext has already been placed in the runtime's application attributes under its full class name (i.e. "javax.servlet.ServletContext").
    • Method Detail

      • init

        public void init​(RuntimeServices rs)
                  throws java.lang.Exception
        init()
        Specified by:
        init in interface LogChute
        Throws:
        java.lang.IllegalStateException - if the ServletContext is not available in the application attributes under the appropriate key.
        java.lang.Exception
      • toLevel

        protected int toLevel​(java.lang.String level)
      • setEnabledLevel

        public void setEnabledLevel​(int level)
        Set the minimum level at which messages will be printed.
      • getEnabledLevel

        public int getEnabledLevel()
        Returns the current minimum level at which messages will be printed.
      • isLevelEnabled

        public boolean isLevelEnabled​(int level)
        This will return true if the specified level is equal to or higher than the level this LogChute is enabled for.
        Specified by:
        isLevelEnabled in interface LogChute
        Returns:
        True if a level is enabled.
      • log

        public void log​(int level,
                        java.lang.String message)
        Send a log message from Velocity.
        Specified by:
        log in interface LogChute
      • log

        public void log​(int level,
                        java.lang.String message,
                        java.lang.Throwable t)
        Description copied from interface: LogChute
        Send a log message from Velocity along with an exception or error
        Specified by:
        log in interface LogChute