Class Slf4JLogger

  • All Implemented Interfaces:
    Logger

    public class Slf4JLogger
    extends java.lang.Object
    implements Logger
    ESAPI Logger implementation which relays events to an SLF4J delegate.
    • Constructor Summary

      Constructors 
      Constructor Description
      Slf4JLogger​(org.slf4j.Logger slf4JLogger, Slf4JLogBridge bridge, int defaultEsapiLevel)
      Constructs a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void always​(Logger.EventType type, java.lang.String message)
      Log an event regardless of what logging level is enabled.
      void always​(Logger.EventType type, java.lang.String message, java.lang.Throwable throwable)
      Log an event regardless of what logging level is enabled and also record the stack trace associated with the event.
      void debug​(Logger.EventType type, java.lang.String message)
      Log a debug level security event if 'debug' level logging is enabled.
      void debug​(Logger.EventType type, java.lang.String message, java.lang.Throwable throwable)
      Log a debug level security event if 'debug' level logging is enabled and also record the stack trace associated with the event.
      void error​(Logger.EventType type, java.lang.String message)
      Log an error level security event if 'error' level logging is enabled.
      void error​(Logger.EventType type, java.lang.String message, java.lang.Throwable throwable)
      Log an error level security event if 'error' level logging is enabled and also record the stack trace associated with the event.
      void fatal​(Logger.EventType type, java.lang.String message)
      Log a fatal event if 'fatal' level logging is enabled.
      void fatal​(Logger.EventType type, java.lang.String message, java.lang.Throwable throwable)
      Log a fatal level security event if 'fatal' level logging is enabled and also record the stack trace associated with the event.
      int getESAPILevel()
      Retrieve the current ESAPI logging level for this logger.
      void info​(Logger.EventType type, java.lang.String message)
      Log an info level security event if 'info' level logging is enabled.
      void info​(Logger.EventType type, java.lang.String message, java.lang.Throwable throwable)
      Log an info level security event if 'info' level logging is enabled and also record the stack trace associated with the event.
      boolean isDebugEnabled()
      Allows the caller to determine if messages logged at this level will be discarded, to avoid performing expensive processing.
      boolean isErrorEnabled()
      Allows the caller to determine if messages logged at this level will be discarded, to avoid performing expensive processing.
      boolean isFatalEnabled()
      Allows the caller to determine if messages logged at this level will be discarded, to avoid performing expensive processing.
      boolean isInfoEnabled()
      Allows the caller to determine if messages logged at this level will be discarded, to avoid performing expensive processing.
      boolean isTraceEnabled()
      Allows the caller to determine if messages logged at this level will be discarded, to avoid performing expensive processing.
      boolean isWarningEnabled()
      Allows the caller to determine if messages logged at this level will be discarded, to avoid performing expensive processing.
      void setLevel​(int level)
      Dynamically set the ESAPI logging severity level.
      void trace​(Logger.EventType type, java.lang.String message)
      Log a trace level security event if 'trace' level logging is enabled.
      void trace​(Logger.EventType type, java.lang.String message, java.lang.Throwable throwable)
      Log a trace level security event if 'trace' level logging is enabled and also record the stack trace associated with the event.
      void warning​(Logger.EventType type, java.lang.String message)
      Log a warning level security event if 'warning' level logging is enabled.
      void warning​(Logger.EventType type, java.lang.String message, java.lang.Throwable throwable)
      Log a warning level security event if 'warning' level logging is enabled and also record the stack trace associated with the event.
      • Methods inherited from class java.lang.Object

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

      • Slf4JLogger

        public Slf4JLogger​(org.slf4j.Logger slf4JLogger,
                           Slf4JLogBridge bridge,
                           int defaultEsapiLevel)
        Constructs a new instance.
        Parameters:
        slf4JLogger - Delegate SLF4J logger.
        bridge - Translator for ESAPI -> SLF4J logging events.
        defaultEsapiLevel - Maximum ESAPI log level events to propagate.
    • Method Detail

      • always

        public void always​(Logger.EventType type,
                           java.lang.String message)
        Description copied from interface: Logger
        Log an event regardless of what logging level is enabled.
        Note that logging will not occur if the underlying logging implementation has logging disabled.
        Specified by:
        always in interface Logger
        Parameters:
        type - the type of event
        message - the message to log
      • always

        public void always​(Logger.EventType type,
                           java.lang.String message,
                           java.lang.Throwable throwable)
        Description copied from interface: Logger
        Log an event regardless of what logging level is enabled and also record the stack trace associated with the event.
        Note that logging will not occur if the underlying logging implementation has logging disabled.
        Specified by:
        always in interface Logger
        Parameters:
        type - the type of event
        message - the message to log
        throwable - the exception to be logged
      • trace

        public void trace​(Logger.EventType type,
                          java.lang.String message)
        Description copied from interface: Logger
        Log a trace level security event if 'trace' level logging is enabled.
        Specified by:
        trace in interface Logger
        Parameters:
        type - the type of event
        message - the message to log
      • trace

        public void trace​(Logger.EventType type,
                          java.lang.String message,
                          java.lang.Throwable throwable)
        Description copied from interface: Logger
        Log a trace level security event if 'trace' level logging is enabled and also record the stack trace associated with the event.
        Specified by:
        trace in interface Logger
        Parameters:
        type - the type of event
        message - the message to log
        throwable - the exception to be logged
      • debug

        public void debug​(Logger.EventType type,
                          java.lang.String message)
        Description copied from interface: Logger
        Log a debug level security event if 'debug' level logging is enabled.
        Specified by:
        debug in interface Logger
        Parameters:
        type - the type of event
        message - the message to log
      • debug

        public void debug​(Logger.EventType type,
                          java.lang.String message,
                          java.lang.Throwable throwable)
        Description copied from interface: Logger
        Log a debug level security event if 'debug' level logging is enabled and also record the stack trace associated with the event.
        Specified by:
        debug in interface Logger
        Parameters:
        type - the type of event
        message - the message to log
        throwable - the exception to be logged
      • info

        public void info​(Logger.EventType type,
                         java.lang.String message)
        Description copied from interface: Logger
        Log an info level security event if 'info' level logging is enabled.
        Specified by:
        info in interface Logger
        Parameters:
        type - the type of event
        message - the message to log
      • info

        public void info​(Logger.EventType type,
                         java.lang.String message,
                         java.lang.Throwable throwable)
        Description copied from interface: Logger
        Log an info level security event if 'info' level logging is enabled and also record the stack trace associated with the event.
        Specified by:
        info in interface Logger
        Parameters:
        type - the type of event
        message - the message to log
        throwable - the exception to be logged
      • warning

        public void warning​(Logger.EventType type,
                            java.lang.String message)
        Description copied from interface: Logger
        Log a warning level security event if 'warning' level logging is enabled.
        Specified by:
        warning in interface Logger
        Parameters:
        type - the type of event
        message - the message to log
      • warning

        public void warning​(Logger.EventType type,
                            java.lang.String message,
                            java.lang.Throwable throwable)
        Description copied from interface: Logger
        Log a warning level security event if 'warning' level logging is enabled and also record the stack trace associated with the event.
        Specified by:
        warning in interface Logger
        Parameters:
        type - the type of event
        message - the message to log
        throwable - the exception to be logged
      • error

        public void error​(Logger.EventType type,
                          java.lang.String message)
        Description copied from interface: Logger
        Log an error level security event if 'error' level logging is enabled.
        Specified by:
        error in interface Logger
        Parameters:
        type - the type of event
        message - the message to log
      • error

        public void error​(Logger.EventType type,
                          java.lang.String message,
                          java.lang.Throwable throwable)
        Description copied from interface: Logger
        Log an error level security event if 'error' level logging is enabled and also record the stack trace associated with the event.
        Specified by:
        error in interface Logger
        Parameters:
        type - the type of event
        message - the message to log
        throwable - the exception to be logged
      • fatal

        public void fatal​(Logger.EventType type,
                          java.lang.String message)
        Description copied from interface: Logger
        Log a fatal event if 'fatal' level logging is enabled.
        Specified by:
        fatal in interface Logger
        Parameters:
        type - the type of event
        message - the message to log
      • fatal

        public void fatal​(Logger.EventType type,
                          java.lang.String message,
                          java.lang.Throwable throwable)
        Description copied from interface: Logger
        Log a fatal level security event if 'fatal' level logging is enabled and also record the stack trace associated with the event.
        Specified by:
        fatal in interface Logger
        Parameters:
        type - the type of event
        message - the message to log
        throwable - the exception to be logged
      • getESAPILevel

        public int getESAPILevel()
        Description copied from interface: Logger
        Retrieve the current ESAPI logging level for this logger. See Log4JLogger for an explanation of why this method is not simply called getLevel().
        Specified by:
        getESAPILevel in interface Logger
        Returns:
        The current logging level.
      • isTraceEnabled

        public boolean isTraceEnabled()
        Description copied from interface: Logger
        Allows the caller to determine if messages logged at this level will be discarded, to avoid performing expensive processing.
        Specified by:
        isTraceEnabled in interface Logger
        Returns:
        true if trace level messages will be output to the log
      • isDebugEnabled

        public boolean isDebugEnabled()
        Description copied from interface: Logger
        Allows the caller to determine if messages logged at this level will be discarded, to avoid performing expensive processing.
        Specified by:
        isDebugEnabled in interface Logger
        Returns:
        true if debug level messages will be output to the log
      • isInfoEnabled

        public boolean isInfoEnabled()
        Description copied from interface: Logger
        Allows the caller to determine if messages logged at this level will be discarded, to avoid performing expensive processing.
        Specified by:
        isInfoEnabled in interface Logger
        Returns:
        true if info level messages will be output to the log
      • isWarningEnabled

        public boolean isWarningEnabled()
        Description copied from interface: Logger
        Allows the caller to determine if messages logged at this level will be discarded, to avoid performing expensive processing.
        Specified by:
        isWarningEnabled in interface Logger
        Returns:
        true if warning level messages will be output to the log
      • isErrorEnabled

        public boolean isErrorEnabled()
        Description copied from interface: Logger
        Allows the caller to determine if messages logged at this level will be discarded, to avoid performing expensive processing.
        Specified by:
        isErrorEnabled in interface Logger
        Returns:
        true if error level messages will be output to the log
      • isFatalEnabled

        public boolean isFatalEnabled()
        Description copied from interface: Logger
        Allows the caller to determine if messages logged at this level will be discarded, to avoid performing expensive processing.
        Specified by:
        isFatalEnabled in interface Logger
        Returns:
        true if fatal level messages will be output to the log
      • setLevel

        public void setLevel​(int level)
        Description copied from interface: Logger
        Dynamically set the ESAPI logging severity level. All events of this level and higher will be logged from this point forward for all logs. All events below this level will be discarded.
        Specified by:
        setLevel in interface Logger
        Parameters:
        level - The level to set the logging level to.