Class LogLevelAdjuster

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

    public class LogLevelAdjuster
    extends java.lang.Object
    implements org.junit.rules.MethodRule
    A JUnit method @Rule that changes the logger level for a set of classes while a test method is running. Useful for performance or scalability tests where we don't want to generate a large log in a tight inner loop. As well as adjusting Log4j, this also adjusts loggers for logback. The amqp-client library now uses slf4j. Since we have logback on the CP (for the appender) we can't add the slf4j-log4j bridge as well.
    Author:
    Dave Syer, Artem Bilan, Gary Russell
    • Constructor Summary

      Constructors 
      Constructor Description
      LogLevelAdjuster​(org.apache.logging.log4j.Level level, java.lang.Class<?>... classes)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.junit.runners.model.Statement apply​(org.junit.runners.model.Statement base, org.junit.runners.model.FrameworkMethod method, java.lang.Object target)  
      LogLevelAdjuster categories​(java.lang.String... categoriesToAdjust)  
      • Methods inherited from class java.lang.Object

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

      • LogLevelAdjuster

        public LogLevelAdjuster​(org.apache.logging.log4j.Level level,
                                java.lang.Class<?>... classes)
    • Method Detail

      • categories

        public LogLevelAdjuster categories​(java.lang.String... categoriesToAdjust)
      • apply

        public org.junit.runners.model.Statement apply​(org.junit.runners.model.Statement base,
                                                       org.junit.runners.model.FrameworkMethod method,
                                                       java.lang.Object target)
        Specified by:
        apply in interface org.junit.rules.MethodRule