Closed as not planned
Closed as not planned
Description
configurations {
implementation {
exclude(module = "spring-boot-starter-logging")
}
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter")
implementation("org.springframework.boot:spring-boot-starter-log4j2")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
package com.example.demo;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.jmx.support.MBeanServerFactoryBean;
import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest
class DemoApplicationTests {
@Test
void contextLoads() {
var factory = new MBeanServerFactoryBean();
factory.setLocateExistingServerIfPossible(true);
factory.afterPropertiesSet();
var server = factory.getObject();
assertThat(server.getDomains()).doesNotContain("org.apache.logging.log4j2"); // fails
}
}
JMX support is enabled by default.
https://logging.apache.org/log4j/2.x/manual/jmx.html#enabling-jmx
Related
Spring Boot - Disable JMX by default
JUnit 5 - Disable Log4J JMX beans creation in tests
Ideally the auto-configuration would set log4j2.disableJmx=true
if spring.jmx.enabled=false
thereby no log4j2 JMX beans would be created.
Alternatively, the log4j2.disableJmx
property should be mentioned in at least these two places: