Class TestLoggerResource

  • All Implemented Interfaces:
    org.junit.rules.TestRule

    public class TestLoggerResource
    extends org.junit.rules.ExternalResource
    Utility for auditing logged messages.

    Note: If a parent logger is already defined with a less specific log level, then using the TestLoggerResource can increase the number of log messages received by this logger.

    Example: You define a logger for org.apache.runtime with log level INFO and then use TestLoggerResource to listen on org.apache.runtime.feature with log level DEBUG. In this case, the log output for the parent logger will include DEBUG messages org.apache.runtime.feature.

    Implementation note: Make sure to not expose log4j dependencies in the interface of this class to ease updates in logging infrastructure.

    • Constructor Detail

      • TestLoggerResource

        public TestLoggerResource​(Class<?> clazz,
                                  org.slf4j.event.Level level)