I have a Java 17 Gradle application and use JUnit Jupiter for testing. When I run tests io.micronaut
diligently writes all its numerous DEBUG log messages. I want to change the vebosity level and after consulting the documentation I tried to change the appropriate values in application.yml
and log4j2.xml
in both main
and test
folder without avail. I also tried to change log level on runtime, also without avail.
@BeforeEach
void setUp() {
final Logger logger = (Logger)LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
logger.setLevel(Level.OFF);
The problem is that the original author of the project has inadvertently copy-pasted from another project libraries into the build.gradle
file, so that it has both log4j
and logback
definitions.
implementation("org.apache.logging.log4j:log4j-api")
implementation("ch.qos.logback:logback-classic:1.2.6")
implementation platform("org.apache.logging.log4j:log4j-bom:2.20.0")
runtimeOnly("org.apache.logging.log4j:log4j-core")
runtimeOnly("org.apache.logging.log4j:log4j-slf4j-impl")
and used log4j2.xml
whereas the system internally has used logback
and therefore all my changes had no effect. deleting all log4j
files and using logback.xml
works perfectly.