Class Log4J2Logger

java.lang.Object
org.tentackle.log.log4j2v.Log4J2Logger
All Implemented Interfaces:
Logger

@Service(Logger.class) public class Log4J2Logger extends Object implements Logger
Pluggable logger using org.apache.log4j.

Logger wrapper for Log4J version 2.

Author:
harald
  • Constructor Details

    • Log4J2Logger

      public Log4J2Logger(String name)
      Creates a logger.
      Parameters:
      name - the name of the logger
  • Method Details

    • getLogger

      public static Log4J2Logger getLogger(String name)
      Gets the Log4J2Logger for given name. If a logger with that name already exists, it will be re-used.
      Parameters:
      name - the name of the logger
      Returns:
      the logger
    • getLoggerImpl

      public Object getLoggerImpl()
      Description copied from interface: Logger
      Gets the concrete logger implementation.
      Useful to access the logging-backend.
      Specified by:
      getLoggerImpl in interface Logger
      Returns:
      the logger object
    • isLoggable

      public boolean isLoggable(Logger.Level level)
      Description copied from interface: Logger
      Checks if a message of the given level would actually be logged by this logger.
      Specified by:
      isLoggable in interface Logger
      Parameters:
      level - the logging level
      Returns:
      true if the given logging level is currently being logged
    • log

      public void log(Logger.Level level, String message, Throwable cause)
      Description copied from interface: Logger
      Logs a message.
      Specified by:
      log in interface Logger
      Parameters:
      level - the logging level
      message - the message
      cause - the Throwable associated with log message, null if none
    • log

      public void log(Logger.Level level, Throwable cause, Supplier<String> messageSupplier)
      Description copied from interface: Logger
      Logs a message.
      Specified by:
      log in interface Logger
      Parameters:
      level - the logging level
      cause - the Throwable associated with log message, null if none
      messageSupplier - the message supplier
    • finer

      public void finer(String message)
      Description copied from interface: Logger
      Logs a message with level FINER.
      Specified by:
      finer in interface Logger
      Parameters:
      message - the message
    • fine

      public void fine(String message)
      Description copied from interface: Logger
      Logs a message with level FINE.
      Specified by:
      fine in interface Logger
      Parameters:
      message - the message
    • info

      public void info(String message)
      Description copied from interface: Logger
      Logs a message with level INFO.
      Specified by:
      info in interface Logger
      Parameters:
      message - the message
    • warning

      public void warning(String message)
      Description copied from interface: Logger
      Logs a message with level WARNING.
      Specified by:
      warning in interface Logger
      Parameters:
      message - the message
    • severe

      public void severe(String message)
      Description copied from interface: Logger
      Logs a message with level SEVERE.
      Specified by:
      severe in interface Logger
      Parameters:
      message - the message
    • finer

      public void finer(String message, Object... params)
      Description copied from interface: Logger
      Logs a message with level FINER.
      Specified by:
      finer in interface Logger
      Parameters:
      message - the message
      params - message parameters
    • fine

      public void fine(String message, Object... params)
      Description copied from interface: Logger
      Logs a message with level FINE.
      Specified by:
      fine in interface Logger
      Parameters:
      message - the message
      params - message parameters
    • info

      public void info(String message, Object... params)
      Description copied from interface: Logger
      Logs a message with level INFO.
      Specified by:
      info in interface Logger
      Parameters:
      message - the message
      params - message parameters
    • warning

      public void warning(String message, Object... params)
      Description copied from interface: Logger
      Logs a message with level WARNING.
      Specified by:
      warning in interface Logger
      Parameters:
      message - the message
      params - message parameters
    • severe

      public void severe(String message, Object... params)
      Description copied from interface: Logger
      Logs a message with level SEVERE.
      Specified by:
      severe in interface Logger
      Parameters:
      message - the message
      params - message parameters
    • finer

      public void finer(String message, Supplier<?>... paramSuppliers)
      Description copied from interface: Logger
      Logs a message with level FINER.
      Specified by:
      finer in interface Logger
      Parameters:
      message - the message
      paramSuppliers - message parameter suppliers
    • fine

      public void fine(String message, Supplier<?>... paramSuppliers)
      Description copied from interface: Logger
      Logs a message with level FINE.
      Specified by:
      fine in interface Logger
      Parameters:
      message - the message
      paramSuppliers - message parameter suppliers
    • info

      public void info(String message, Supplier<?>... paramSuppliers)
      Description copied from interface: Logger
      Logs a message with level INFO.
      Specified by:
      info in interface Logger
      Parameters:
      message - the message
      paramSuppliers - message parameter suppliers
    • warning

      public void warning(String message, Supplier<?>... paramSuppliers)
      Description copied from interface: Logger
      Logs a message with level WARNING.
      Specified by:
      warning in interface Logger
      Parameters:
      message - the message
      paramSuppliers - message parameter suppliers
    • severe

      public void severe(String message, Supplier<?>... paramSuppliers)
      Description copied from interface: Logger
      Logs a message with level SEVERE.
      Specified by:
      severe in interface Logger
      Parameters:
      message - the message
      paramSuppliers - message parameter suppliers
    • finer

      public void finer(String message, Throwable cause)
      Description copied from interface: Logger
      Logs a message with level FINER.
      Specified by:
      finer in interface Logger
      Parameters:
      message - the message
      cause - the throwable
    • fine

      public void fine(String message, Throwable cause)
      Description copied from interface: Logger
      Logs a message with level FINE.
      Specified by:
      fine in interface Logger
      Parameters:
      message - the message
      cause - the throwable
    • info

      public void info(String message, Throwable cause)
      Description copied from interface: Logger
      Logs a message with level INFO.
      Specified by:
      info in interface Logger
      Parameters:
      message - the message
      cause - the throwable
    • warning

      public void warning(String message, Throwable cause)
      Description copied from interface: Logger
      Logs a message with level WARNING.
      Specified by:
      warning in interface Logger
      Parameters:
      message - the message
      cause - the throwable
    • severe

      public void severe(String message, Throwable cause)
      Description copied from interface: Logger
      Logs a message with level SEVERE.
      Specified by:
      severe in interface Logger
      Parameters:
      message - the message
      cause - the throwable
    • finer

      public void finer(Throwable cause, Supplier<String> messageSupplier)
      Description copied from interface: Logger
      Logs a message with level FINER.
      Specified by:
      finer in interface Logger
      Parameters:
      cause - the throwable
      messageSupplier - the message supplier
    • fine

      public void fine(Throwable cause, Supplier<String> messageSupplier)
      Description copied from interface: Logger
      Logs a message with level FINE.
      Specified by:
      fine in interface Logger
      Parameters:
      cause - the throwable
      messageSupplier - the message supplier
    • info

      public void info(Throwable cause, Supplier<String> messageSupplier)
      Description copied from interface: Logger
      Logs a message with level INFO.
      Specified by:
      info in interface Logger
      Parameters:
      cause - the throwable
      messageSupplier - the message supplier
    • warning

      public void warning(Throwable cause, Supplier<String> messageSupplier)
      Description copied from interface: Logger
      Logs a message with level WARNING.
      Specified by:
      warning in interface Logger
      Parameters:
      cause - the throwable
      messageSupplier - the message supplier
    • severe

      public void severe(Throwable cause, Supplier<String> messageSupplier)
      Description copied from interface: Logger
      Logs a message with level SEVERE.
      Specified by:
      severe in interface Logger
      Parameters:
      cause - the throwable
      messageSupplier - the message supplier
    • finer

      public void finer(Supplier<String> messageSupplier)
      Description copied from interface: Logger
      Logs a message with level FINER.
      Specified by:
      finer in interface Logger
      Parameters:
      messageSupplier - the message supplier
    • fine

      public void fine(Supplier<String> messageSupplier)
      Description copied from interface: Logger
      Logs a message with level FINE.
      Specified by:
      fine in interface Logger
      Parameters:
      messageSupplier - the message supplier
    • info

      public void info(Supplier<String> messageSupplier)
      Description copied from interface: Logger
      Logs a message with level INFO.
      Specified by:
      info in interface Logger
      Parameters:
      messageSupplier - the message supplier
    • warning

      public void warning(Supplier<String> messageSupplier)
      Description copied from interface: Logger
      Logs a message with level WARNING.
      Specified by:
      warning in interface Logger
      Parameters:
      messageSupplier - the message supplier
    • severe

      public void severe(Supplier<String> messageSupplier)
      Description copied from interface: Logger
      Logs a message with level SEVERE.
      Specified by:
      severe in interface Logger
      Parameters:
      messageSupplier - the message supplier
    • isFinerLoggable

      public boolean isFinerLoggable()
      Description copied from interface: Logger
      Checks if logger logs level FINER.
      Specified by:
      isFinerLoggable in interface Logger
      Returns:
      true if logger will log this level
    • isFineLoggable

      public boolean isFineLoggable()
      Description copied from interface: Logger
      Checks if logger logs level FINE.
      Specified by:
      isFineLoggable in interface Logger
      Returns:
      true if logger will log this level
    • isInfoLoggable

      public boolean isInfoLoggable()
      Description copied from interface: Logger
      Checks if logger logs level INFO.
      Specified by:
      isInfoLoggable in interface Logger
      Returns:
      true if logger will log this level
    • isWarningLoggable

      public boolean isWarningLoggable()
      Description copied from interface: Logger
      Checks if logger logs level WARNING.
      Specified by:
      isWarningLoggable in interface Logger
      Returns:
      true if logger will log this level
    • isSevereLoggable

      public boolean isSevereLoggable()
      Description copied from interface: Logger
      Checks if logger logs level SEVERE.
      Specified by:
      isSevereLoggable in interface Logger
      Returns:
      true if logger will log this level
    • logStacktrace

      public void logStacktrace(Logger.Level level, Throwable cause)
      Logs the stacktrace of a throwable.
      Specified by:
      logStacktrace in interface Logger
      Parameters:
      level - the logging level
      cause - the Throwable to log the stacktrace for
    • logStacktrace

      public void logStacktrace(Throwable cause)
      Logs the stacktrace of a throwable with a logging level of SEVERE.
      Specified by:
      logStacktrace in interface Logger
      Parameters:
      cause - the Throwable to log the stacktrace for
    • getMappedDiagnosticContext

      public MappedDiagnosticContext getMappedDiagnosticContext()
      Description copied from interface: Logger
      Gets the MDC.
      Usually a singleton (depending on the backend).
      Specified by:
      getMappedDiagnosticContext in interface Logger
      Returns:
      the MDC
    • doLog

      protected void doLog(Logger.Level level, String message, Throwable cause, Object... params)
      Logging workhorse.
      Parameters:
      level - the log level
      message - the message
      cause - the cause
      params - optional parameters
    • doLog

      protected void doLog(Logger.Level level, Throwable cause, String message, Supplier<?>... paramSuppliers)
      Logging workhorse.
      Parameters:
      level - the log level
      cause - the cause
      message - the message
      paramSuppliers - parameter suppliers
    • doLog

      protected void doLog(Logger.Level level, Throwable cause, String message, Supplier<String> messageSupplier)
      Logging workhorse.
      Parameters:
      level - the log level
      cause - the cause, null if none
      message - the message, null if messageSupplier
      messageSupplier - the message supplier, null if message