title: Should we unit test logging?
body: <p>It's usual to see logging functionality in the code:</p>
  
  <pre><code>public class A {
  
      private static final Log LOG = LogFactory.getLog(A.class);
  </code></pre>
  
  <p>and usage:</p>
  
  <pre><code>} catch (Exception e) {
      LOG.error(e.getMessage(), e);
      throw e;
  }
  </code></pre>
  
  <p>but I never saw even single unit test for such code. </p>
  
  <p>Off course I do test throwing exception and exception type, but should I write test for checking logging information? I tend to think that logging is another part of system behavior, so it's quit logically to cover it in the tests.</p>
  
  <p>Assuming that I should cover it, means that I should change my original code to inject mock log and check that "error" method was invoked with expected message. But what to do if my original class is service and it's instantiated by spring, should I inject some logger as well as other dependencies?</p>