diff --git a/micrometer-core/src/test/java/io/micrometer/core/instrument/binder/logging/Log4j2MetricsTest.java b/micrometer-core/src/test/java/io/micrometer/core/instrument/binder/logging/Log4j2MetricsTest.java index 77b774d723..1b3ca36eae 100644 --- a/micrometer-core/src/test/java/io/micrometer/core/instrument/binder/logging/Log4j2MetricsTest.java +++ b/micrometer-core/src/test/java/io/micrometer/core/instrument/binder/logging/Log4j2MetricsTest.java @@ -187,9 +187,8 @@ void asyncLogShouldNotBeDuplicated() throws IOException { @Issue("#5756") @Test void rebindsMetricsWhenConfigurationIsReloaded() { - MeterRegistry registry = new SimpleMeterRegistry(); - LoggerContext context = (LoggerContext) LogManager.getContext(false); - Logger logger = context.getLogger(getClass()); + LoggerContext context = new LoggerContext("test"); + Logger logger = context.getLogger("com.test"); try (Log4j2Metrics metrics = new Log4j2Metrics(emptyList(), context)) { metrics.bindTo(registry); @@ -208,9 +207,8 @@ void rebindsMetricsWhenConfigurationIsReloaded() { @Test void shouldNotRebindMetricsIfBinderIsClosed() { - MeterRegistry registry = new SimpleMeterRegistry(); - LoggerContext context = (LoggerContext) LogManager.getContext(false); - Logger logger = context.getLogger(getClass()); + LoggerContext context = new LoggerContext("test"); + Logger logger = context.getLogger("com.test"); try (Log4j2Metrics metrics = new Log4j2Metrics(emptyList(), context)) { metrics.bindTo(registry);