title: How to do a JUnit assert on a message in a logger
body: <p>I have some code-under-test that calls on a Java logger to report its status.
  In the JUnit test code, I would like to verify that the correct log entry was made in this logger. Something along the following lines:</p>
  
  <pre><code>methodUnderTest(bool x){
      if(x)
          logger.info("x happened")
  }
  
  @Test tester(){
      // perhaps setup a logger first.
      methodUnderTest(true);
      assertXXXXXX(loggedLevel(),Level.INFO);
  }
  </code></pre>
  
  <p>I suppose that this could be done with a specially adapted logger (or handler, or formatter), but I would prefer to re-use a solution that already exists. (And, to be honest, it is not clear to me how to get at the logRecord from a logger, but suppose that that's possible.)</p>