Testing logging to log files

Recommended reading before you read this article: Mockito basics

How do we test logging to logs?

We should not do that in general. The solution might be to test if notifications are being sent to support or diagnostic teams though. The implementation of those notifications might go to logs. For example:

A sample implementation of SupportTeam interface might look like this:

The examples above hide logging behind a SupportTeam interface. This seems to be a good modelling example of the real world scenarios. Who looks at the production logs in the real world? Support team in most cases. Then we should notify support team when exception occurs instead of logging to logs. The implementation of SupportTeam interface can log to logs though. Modelling the real world scenarios is in my opinion one of the key OO principles that people often forget about.

Please comment!