I was peer reviewing some code today which had loads of assertions to check that specific logs were being produced at various points during the execution of the application and this got me wondering whether it is worth doing this.
To me it seems like a bit of an anti-pattern as it's breaking the encapsulation of the underlying methods and components, since it's expecting specific log strings to be present at various points or when certain functions are called.
By expecting these logs to be created instead of just asserting the outputs of the application, the tests become brittle and prone to break from small refactors like shuffling said logs around or simply by rewording them.
In my opinion logs should not be under test, but perhaps there are valid reasons for doing so which I don't know. What do you folks think?