Class Log4JLoggerWrapper

  • All Implemented Interfaces:
    ILogger

    public class Log4JLoggerWrapper
    extends java.lang.Object
    implements ILogger
    An implementation of ILogger that delegates the calls to the log4j2 library.

    This class also configures the log4j2 library to use the configuration file at <configPath>/lumislogconfig.yml.

    Since:
    4.0.0
    Version:
    $Revision: 26035 $ $Date: 2023-11-30 14:49:12 -0300 (Thu, 30 Nov 2023) $
    See Also:
    ILogger
    • Nested Class Summary

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected org.apache.logging.log4j.Logger log4jLogger
      The log4j logger instance that is being wrapped.
    • Constructor Summary

      Constructors 
      Constructor Description
      Log4JLoggerWrapper​(java.lang.Class<?> pClass)
      Creates a wrapper for the log4j logger for the given class.
      Log4JLoggerWrapper​(java.lang.String pCategoryName)
      Creates a wrapper for the log4j logger for the given category name.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void debug​(java.lang.Object msg)
      Log a message with debug log level.
      void debug​(java.lang.Object msg, java.lang.Throwable t)
      Log an error with debug log level.
      void debug​(java.util.function.Supplier<?> messageSupplier)
      Log a message with debug log level.
      The message will be generated by the given supplier.
      The supplier will only be invoked if the debug level is enabled.
      void debug​(java.util.function.Supplier<?> messageSupplier, java.lang.Throwable t)
      Log a message with debug log level and the given cause.
      The message will be generated by the given supplier.
      The supplier will only be invoked if the debug level is enabled.
      void error​(java.lang.Object msg)
      Log a message with error log level.
      void error​(java.lang.Object msg, java.lang.Throwable t)
      Log an error with error log level.
      void error​(java.util.function.Supplier<?> messageSupplier)
      Log a message with error log level.
      The message will be generated by the given supplier.
      The supplier will only be invoked if the error level is enabled.
      void error​(java.util.function.Supplier<?> messageSupplier, java.lang.Throwable t)
      Log a message with error log level and the given cause.
      The message will be generated by the given supplier.
      The supplier will only be invoked if the error level is enabled.
      void fatal​(java.lang.Object msg)
      Log a message with fatal log level.
      void fatal​(java.lang.Object msg, java.lang.Throwable t)
      Log an error with fatal log level.
      void fatal​(java.util.function.Supplier<?> messageSupplier)
      Log a message with fatal log level.
      The message will be generated by the given supplier.
      The supplier will only be invoked if the fatal level is enabled.
      void fatal​(java.util.function.Supplier<?> messageSupplier, java.lang.Throwable t)
      Log a message with fatal log level and the given cause.
      The message will be generated by the given supplier.
      The supplier will only be invoked if the fatal level is enabled.
      ILogger.Level getLevel()
      Returns the current minimum logging level logged by this instance.
      void info​(java.lang.Object msg)
      Log a message with info log level.
      void info​(java.lang.Object msg, java.lang.Throwable t)
      Log an error with info log level.
      void info​(java.util.function.Supplier<?> messageSupplier)
      Log a message with info log level.
      The message will be generated by the given supplier.
      The supplier will only be invoked if the info level is enabled.
      void info​(java.util.function.Supplier<?> messageSupplier, java.lang.Throwable t)
      Log a message with info log level and the given cause.
      The message will be generated by the given supplier.
      The supplier will only be invoked if the info level is enabled.
      boolean isDebugEnabled()
      Is debug logging currently enabled?
      boolean isErrorEnabled()
      Is error logging currently enabled?
      boolean isFatalEnabled()
      Is fatal logging currently enabled?
      static boolean isGlobalFilterDenyingDebug()
      Returns whether the global level filter in log4j2 is denying debug level logs.
      boolean isInfoEnabled()
      Is info logging currently enabled?
      boolean isWarnEnabled()
      Is warn logging currently enabled?
      static void shutdown()
      Shuts down the LumisXP Log4j integration.
      void warn​(java.lang.Object msg)
      Log a message with warn log level.
      void warn​(java.lang.Object msg, java.lang.Throwable t)
      Log an error with warn log level.
      void warn​(java.util.function.Supplier<?> messageSupplier)
      Log a message with warn log level.
      The message will be generated by the given supplier.
      The supplier will only be invoked if the warn level is enabled.
      void warn​(java.util.function.Supplier<?> messageSupplier, java.lang.Throwable t)
      Log a message with warn log level and the given cause.
      The message will be generated by the given supplier.
      The supplier will only be invoked if the warn level is enabled.
      • Methods inherited from class java.lang.Object

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

      • log4jLogger

        protected org.apache.logging.log4j.Logger log4jLogger
        The log4j logger instance that is being wrapped.
    • Constructor Detail

      • Log4JLoggerWrapper

        public Log4JLoggerWrapper​(java.lang.Class<?> pClass)
        Creates a wrapper for the log4j logger for the given class.
        See Also:
        Logger#getLogger(java.lang.Class)
      • Log4JLoggerWrapper

        public Log4JLoggerWrapper​(java.lang.String pCategoryName)
        Creates a wrapper for the log4j logger for the given category name.
        See Also:
        Logger#getLogger(java.lang.String)
    • Method Detail

      • shutdown

        public static void shutdown()
        Shuts down the LumisXP Log4j integration.
        Since:
        14.2.0
      • debug

        public void debug​(java.lang.Object msg)
        Description copied from interface: ILogger

        Log a message with debug log level.

        Specified by:
        debug in interface ILogger
        Parameters:
        msg - log this message
      • debug

        public void debug​(java.lang.Object msg,
                          java.lang.Throwable t)
        Description copied from interface: ILogger

        Log an error with debug log level.

        Specified by:
        debug in interface ILogger
        Parameters:
        msg - log this message
        t - log this cause
      • debug

        public void debug​(java.util.function.Supplier<?> messageSupplier)
        Description copied from interface: ILogger
        Log a message with debug log level.
        The message will be generated by the given supplier.
        The supplier will only be invoked if the debug level is enabled.
        Specified by:
        debug in interface ILogger
        Parameters:
        messageSupplier - the message supplier
      • debug

        public void debug​(java.util.function.Supplier<?> messageSupplier,
                          java.lang.Throwable t)
        Description copied from interface: ILogger
        Log a message with debug log level and the given cause.
        The message will be generated by the given supplier.
        The supplier will only be invoked if the debug level is enabled.
        Specified by:
        debug in interface ILogger
        Parameters:
        messageSupplier - the message supplier
        t - the cause
      • error

        public void error​(java.lang.Object msg)
        Description copied from interface: ILogger

        Log a message with error log level.

        Specified by:
        error in interface ILogger
        Parameters:
        msg - log this message
      • error

        public void error​(java.lang.Object msg,
                          java.lang.Throwable t)
        Description copied from interface: ILogger

        Log an error with error log level.

        Specified by:
        error in interface ILogger
        Parameters:
        msg - log this message
        t - log this cause
      • error

        public void error​(java.util.function.Supplier<?> messageSupplier)
        Description copied from interface: ILogger
        Log a message with error log level.
        The message will be generated by the given supplier.
        The supplier will only be invoked if the error level is enabled.
        Specified by:
        error in interface ILogger
        Parameters:
        messageSupplier - the message supplier
      • error

        public void error​(java.util.function.Supplier<?> messageSupplier,
                          java.lang.Throwable t)
        Description copied from interface: ILogger
        Log a message with error log level and the given cause.
        The message will be generated by the given supplier.
        The supplier will only be invoked if the error level is enabled.
        Specified by:
        error in interface ILogger
        Parameters:
        messageSupplier - the message supplier
        t - the cause
      • fatal

        public void fatal​(java.lang.Object msg)
        Description copied from interface: ILogger

        Log a message with fatal log level.

        Specified by:
        fatal in interface ILogger
        Parameters:
        msg - log this message
      • fatal

        public void fatal​(java.lang.Object msg,
                          java.lang.Throwable t)
        Description copied from interface: ILogger

        Log an error with fatal log level.

        Specified by:
        fatal in interface ILogger
        Parameters:
        msg - log this message
        t - log this cause
      • fatal

        public void fatal​(java.util.function.Supplier<?> messageSupplier)
        Description copied from interface: ILogger
        Log a message with fatal log level.
        The message will be generated by the given supplier.
        The supplier will only be invoked if the fatal level is enabled.
        Specified by:
        fatal in interface ILogger
        Parameters:
        messageSupplier - the message supplier
      • fatal

        public void fatal​(java.util.function.Supplier<?> messageSupplier,
                          java.lang.Throwable t)
        Description copied from interface: ILogger
        Log a message with fatal log level and the given cause.
        The message will be generated by the given supplier.
        The supplier will only be invoked if the fatal level is enabled.
        Specified by:
        fatal in interface ILogger
        Parameters:
        messageSupplier - the message supplier
        t - the cause
      • info

        public void info​(java.lang.Object msg)
        Description copied from interface: ILogger

        Log a message with info log level.

        Specified by:
        info in interface ILogger
        Parameters:
        msg - log this message
      • info

        public void info​(java.lang.Object msg,
                         java.lang.Throwable t)
        Description copied from interface: ILogger

        Log an error with info log level.

        Specified by:
        info in interface ILogger
        Parameters:
        msg - log this message
        t - log this cause
      • info

        public void info​(java.util.function.Supplier<?> messageSupplier)
        Description copied from interface: ILogger
        Log a message with info log level.
        The message will be generated by the given supplier.
        The supplier will only be invoked if the info level is enabled.
        Specified by:
        info in interface ILogger
        Parameters:
        messageSupplier - the message supplier
      • info

        public void info​(java.util.function.Supplier<?> messageSupplier,
                         java.lang.Throwable t)
        Description copied from interface: ILogger
        Log a message with info log level and the given cause.
        The message will be generated by the given supplier.
        The supplier will only be invoked if the info level is enabled.
        Specified by:
        info in interface ILogger
        Parameters:
        messageSupplier - the message supplier
        t - the cause
      • isDebugEnabled

        public boolean isDebugEnabled()
        Description copied from interface: ILogger

        Is debug logging currently enabled?

        Call this method to prevent having to perform expensive operations (for example, String concatenation) when the log level is more than debug.

        Specified by:
        isDebugEnabled in interface ILogger
      • isInfoEnabled

        public boolean isInfoEnabled()
        Description copied from interface: ILogger

        Is info logging currently enabled?

        Call this method to prevent having to perform expensive operations (for example, String concatenation) when the log level is more than info.

        Specified by:
        isInfoEnabled in interface ILogger
      • isWarnEnabled

        public boolean isWarnEnabled()
        Description copied from interface: ILogger

        Is warn logging currently enabled?

        Call this method to prevent having to perform expensive operations (for example, String concatenation) when the log level is more than warn.

        Specified by:
        isWarnEnabled in interface ILogger
      • isErrorEnabled

        public boolean isErrorEnabled()
        Description copied from interface: ILogger

        Is error logging currently enabled?

        Call this method to prevent having to perform expensive operations (for example, String concatenation) when the log level is more than error.

        Specified by:
        isErrorEnabled in interface ILogger
      • isFatalEnabled

        public boolean isFatalEnabled()
        Description copied from interface: ILogger

        Is fatal logging currently enabled?

        Call this method to prevent having to perform expensive operations (for example, String concatenation) when the log level is more than fatal.

        Specified by:
        isFatalEnabled in interface ILogger
      • warn

        public void warn​(java.lang.Object msg)
        Description copied from interface: ILogger

        Log a message with warn log level.

        Specified by:
        warn in interface ILogger
        Parameters:
        msg - log this message
      • warn

        public void warn​(java.lang.Object msg,
                         java.lang.Throwable t)
        Description copied from interface: ILogger

        Log an error with warn log level.

        Specified by:
        warn in interface ILogger
        Parameters:
        msg - log this message
        t - log this cause
      • warn

        public void warn​(java.util.function.Supplier<?> messageSupplier)
        Description copied from interface: ILogger
        Log a message with warn log level.
        The message will be generated by the given supplier.
        The supplier will only be invoked if the warn level is enabled.
        Specified by:
        warn in interface ILogger
        Parameters:
        messageSupplier - the message supplier
      • warn

        public void warn​(java.util.function.Supplier<?> messageSupplier,
                         java.lang.Throwable t)
        Description copied from interface: ILogger
        Log a message with warn log level and the given cause.
        The message will be generated by the given supplier.
        The supplier will only be invoked if the warn level is enabled.
        Specified by:
        warn in interface ILogger
        Parameters:
        messageSupplier - the message supplier
        t - the cause
      • getLevel

        public ILogger.Level getLevel()
        Description copied from interface: ILogger
        Returns the current minimum logging level logged by this instance.
        Specified by:
        getLevel in interface ILogger
      • isGlobalFilterDenyingDebug

        public static boolean isGlobalFilterDenyingDebug()
        Returns whether the global level filter in log4j2 is denying debug level logs.
        Returns:
        Since:
        14.2.0