Class LogUtils

java.lang.Object
nva.commons.logutils.LogUtils

@Deprecated(since="2.7.2") public final class LogUtils extends Object
Deprecated.
Use LogRecorder instead. It captures events without reconfiguring the global Log4j context, returns structured LogEvents, and avoids side effects on unrelated loggers.
Methods for testing logging when using Log4j2 as logging platform. Can be used when using SLF4J as well with Log4j2 as background logging platform.
  • Field Details

  • Method Details

    • getTestingAppender

      @Deprecated(since="2.7.2") public static <T> TestAppender getTestingAppender(Class<T> clazz)
      Deprecated.
      This method should ALWAYS be called before the creation of the object you want to test.

      The method was created based on the patterns for programmatically configuring Log4j (https://logging.apache.org/log4j/2.x/manual/customconfig.html)

      Type Parameters:
      T - The class of the object under test
      Parameters:
      clazz - The class of the object under test.
      Returns:
      a TestAppender
    • getTestingAppenderForRootLogger

      @Deprecated(since="2.7.2") public static <T> TestAppender getTestingAppenderForRootLogger()
      Deprecated.
      This method should ALWAYS be called before the creation of the object you want to test.

      The method was created based on the patterns for programmatically configuring Log4j (https://logging.apache.org/log4j/2.x/manual/customconfig.html)

      Type Parameters:
      T - The class of the object under test
      Returns:
      a TestAppender
    • toLoggerName

      public static String toLoggerName(Class<?> cls)
      Deprecated.
      From LogManager.getLogger()
      Parameters:
      cls - the class
      Returns:
      the logger name