a quick approach/sample for unit testing logs using SL4FJ
and Logging
from com.devexperts.logging.Logging
Does something very simple:
- Extends an
org.apache.logging.log4j.core.Appender
- Mocks an appender using Mockito
- Get general context in use and add this custom appender (1 or 2)
- Those appenders have associated
Lists
to store log events/messages so when can assert later.
This whole thing is very raw, but illustrates an issue that I had when I got a ticket related to logging, and I've been trying to use more TDD in my walk every single day.