Class DefaultErrorHandler

java.lang.Object
org.apache.logging.log4j.core.appender.DefaultErrorHandler
All Implemented Interfaces:
ErrorHandler

public class DefaultErrorHandler extends Object implements ErrorHandler
The default ErrorHandler implementation falling back to StatusLogger.

It avoids flooding the StatusLogger by allowing either the first 3 errors or errors once every 5 minutes.

  • Field Details

    • LOGGER

      private static final Logger LOGGER
    • MAX_EXCEPTION_COUNT

      private static final int MAX_EXCEPTION_COUNT
      See Also:
    • EXCEPTION_INTERVAL_NANOS

      private static final long EXCEPTION_INTERVAL_NANOS
    • exceptionCount

      private int exceptionCount
    • lastExceptionInstantNanos

      private long lastExceptionInstantNanos
    • appender

      private final Appender appender
  • Constructor Details

    • DefaultErrorHandler

      public DefaultErrorHandler(Appender appender)
  • Method Details

    • error

      public void error(String msg)
      Handle an error with a message.
      Specified by:
      error in interface ErrorHandler
      Parameters:
      msg - a message
    • error

      public void error(String msg, Throwable error)
      Handle an error with a message and an exception.
      Specified by:
      error in interface ErrorHandler
      Parameters:
      msg - a message
      error - a Throwable
    • error

      public void error(String msg, LogEvent event, Throwable error)
      Handle an error with a message, an exception, and a logging event.
      Specified by:
      error in interface ErrorHandler
      Parameters:
      msg - a message
      event - a LogEvent
      error - a Throwable
    • acquirePermit

      private boolean acquirePermit()
    • getAppender

      public Appender getAppender()