title: Python mocking logging while retaining log output
body: <p>I have a series of unit/integration tests which using the python <code>logging module</code>.  I would like to test that the right things are logged when appropriate which I can achieve using the <code>mock</code> module as follows:</p>
  
  <pre><code>@mock.patch('logging.Logger.info')
  </code></pre>
  
  <p>However, when I do this the actual logging is stopped (for obvious reasons!) and this is useful for me to debug why my tests are working etc.</p>
  
  <p>My question is as follows:  Is there a way in why I can mock out logging calls so I can assert they have been called with the expected arguments but still keep the logging functionality?</p>
  
  <p>My current approach is to make a wrapper class which contains a MagicMock and an un-mocked logger:</p>
  
  <pre><code>class MonkeyPatchLogger(object):
      MOCK = mock.MagicMock()
      @classmethod
      def info(cls, *args, **kwargs):
          cls.MOCK(*args, **kwargs)
          logger.info(*args, **kwargs)
  </code></pre>
  
  <p>but this isn't working.</p>
  
  <p>Cheers,
  Jack</p>