Skip to main content

Tag: unit test

Unit testing a static custom logger in Spring Boot and log4j2

Last time I wrote a post about how to unit test a custom logger with log4j2. Today I migrated another custom logger from log4j 1.x to log4j 2.x, but this time it was encapsulated in a Spring Boot component as a static class attribute. Custom logger You have a simple custom logger public class SimpleCustomLogger { private final ExtendedLoggerWrapper log; private SimpleCustomLogger(final Logger log) { this.log = new ExtendedLoggerWrapper((AbstractLogger) log, log.

Unit testing a custom logger in log4j2

In this period I’m upgrading a Spring Boot project from 1.3 –> 1.5 –> 2.0. One of the steps is to get rid of log4j 1.x. In the project there is custom logger, but unfortunately its unit test with log4j2 is no more working and we receive the following error: mockito wanted but not invoked, Actually there were zero interactions with this mock Basically this exact same error in Stackoverflow.