Sometimes you want to test if certain log output gets generated whencertain events happen in your application. Here is how I unit test thatusing log4j2 (version 2.11.0). Use LoggerContextRule to get to your ListAppender quickly If you are using JUnit 4, then the quickest solution would be one thatis used by log4j2itself: importorg.apache.logging.log4j.junit.LoggerContextRule;/* other imports */publicclassLogEventTest{privatestaticListAppenderappender;@ClassRulepublicstaticLoggerContextRuleini...