Class Log4J2Logger


  • public final class Log4J2Logger
    extends LoggerAdapter
    An adapter that redirect all Java logging events to the Apache's Log4J framework.

    Level conversions align with Log4j JDK Logging Adapter:

    • Level.OFF: Level.OFF
    • Logging.FATAL: Level.FATAL
    • Level.SEVERE: Level.ERROR
    • Level.WARNING: Level.WARN
    • Level.INFO: Level.INFO
    • Level.CONFIG: CONFIG
    • Level.FINE: Level.DEBUG
    • Level.FINER: Level.TRACE
    • Level.FINEST: FINEST
    • Level.ALL: Level.ALL
    To configure these additional levels use:
    >code>    >CustomLevels>
          >CustomLevel name="CONFIG" intLevel="450" /<
         >CustomLevel name="FINEST" intLevel="700" /<
       >/CustomLevels<
    Since:
    27
    Author:
    Jody Garnett (GeoCat)
    See Also:
    Log4J2LoggerFactory, Logging
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static Level CONFIG
      Define a Log4j Level mapping to java util logging Level.CONFIG (using StandardLevel value 450).
      static Level FINEST
      Define a Log4j Level mapping to java util logging Level.FINEST Level (using StandardLevel value 700 which is higher the DEBUG).
      • Fields inherited from class Logger

        global, GLOBAL_LOGGER_NAME
    • Constructor Summary

      Constructors 
      Constructor Description
      Log4J2Logger​(String name, Logger logger)
      Creates a new logger adapter mapping from Log4J to java util logging.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void config​(String message)
      Logs an CONFIG message.
      void fine​(String message)
      Logs a FINE message.
      void finer​(String message)
      Logs a FINER message.
      void finest​(String message)
      Logs a FINEST message.
      Level getLevel()
      Returns the level for this logger.
      void info​(String message)
      Logs an INFO message.
      boolean isLoggable​(Level level)
      Returns true if the specified level is loggable.
      void log​(Level level, String message)
      Logs a record at the specified level.
      void log​(Level level, String message, Throwable thrown)
      Logs a record at the specified level.
      void setLevel​(Level level)
      Set the level for this logger.
      void severe​(String message)
      Logs a SEVERE message.
      String toString()  
      void warning​(String message)
      Logs a WARNING message.
      • Methods inherited from class Logger

        config, fine, finer, finest, getAnonymousLogger, getAnonymousLogger, getFilter, getGlobal, getHandlers, getLogger, getLogger, getName, getParent, getResourceBundle, getResourceBundleName, getUseParentHandlers, info, log, log, logp, logp, logrb, logrb, logrb, logrb, setResourceBundle, severe, warning
      • Methods inherited from class Object

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

      • CONFIG

        public static final Level CONFIG
        Define a Log4j Level mapping to java util logging Level.CONFIG (using StandardLevel value 450).

        Note: StandardLevel.getStandardLevel(int) will map to StandardLevel.INFO if using a log4j adapter (StandardLevel value 550 between Level.INFO and Level.DEBUG).

      • FINEST

        public static final Level FINEST
        Define a Log4j Level mapping to java util logging Level.FINEST Level (using StandardLevel value 700 which is higher the DEBUG).

        Note: StandardLevel.getStandardLevel(int) will map to StandardLevel.DEBUG if using a log4j adapter.

    • Constructor Detail

      • Log4J2Logger

        public Log4J2Logger​(String name,
                            Logger logger)
        Creates a new logger adapter mapping from Log4J to java util logging.
        Parameters:
        name - The logger name.
        logger - The result of Logger.getLogger(name).
    • Method Detail

      • setLevel

        public void setLevel​(Level level)
        Set the level for this logger.
        Specified by:
        setLevel in class LoggerAdapter
      • getLevel

        public Level getLevel()
        Returns the level for this logger.
        Specified by:
        getLevel in class LoggerAdapter
      • isLoggable

        public boolean isLoggable​(Level level)
        Returns true if the specified level is loggable.
        Specified by:
        isLoggable in class LoggerAdapter
      • log

        public void log​(Level level,
                        String message)
        Logs a record at the specified level.
        Overrides:
        log in class LoggerAdapter
      • log

        public void log​(Level level,
                        String message,
                        Throwable thrown)
        Logs a record at the specified level.
        Overrides:
        log in class LoggerAdapter
      • severe

        public void severe​(String message)
        Description copied from class: LoggerAdapter
        Logs a SEVERE message.
        Specified by:
        severe in class LoggerAdapter
      • warning

        public void warning​(String message)
        Description copied from class: LoggerAdapter
        Logs a WARNING message.
        Specified by:
        warning in class LoggerAdapter
      • info

        public void info​(String message)
        Description copied from class: LoggerAdapter
        Logs an INFO message.
        Specified by:
        info in class LoggerAdapter
      • config

        public void config​(String message)
        Description copied from class: LoggerAdapter
        Logs an CONFIG message.
        Specified by:
        config in class LoggerAdapter
      • fine

        public void fine​(String message)
        Description copied from class: LoggerAdapter
        Logs a FINE message.
        Specified by:
        fine in class LoggerAdapter
      • finer

        public void finer​(String message)
        Description copied from class: LoggerAdapter
        Logs a FINER message.
        Specified by:
        finer in class LoggerAdapter
      • finest

        public void finest​(String message)
        Description copied from class: LoggerAdapter
        Logs a FINEST message.
        Specified by:
        finest in class LoggerAdapter