Skip to content

Commit 506e705

Browse files
chore: log4j update
This commit replaces the deprecated createLogger-API with the use of an builder.
1 parent 8c89d6e commit 506e705

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ subprojects {
1313
ext {
1414
junitVersion = '5.8.2' // https://search.maven.org/artifact/org.junit.jupiter/junit-jupiter-api
1515
logbackVersion = '1.3.7' // https://search.maven.org/artifact/ch.qos.logback/logback-core
16-
log4j2Version = '2.17.1' // https://search.maven.org/artifact/org.apache.logging.log4j/log4j-core
16+
log4j2Version = '2.20.0' // https://search.maven.org/artifact/org.apache.logging.log4j/log4j-core
1717
slf4jVersion = '2.0.7' // https://search.maven.org/artifact/org.slf4j/slf4j-api
1818
}
1919

logunit-log4j2/src/main/java/io/github/netmikey/logunit/log4j2/Log4j2LogProvider.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,13 @@ private void createLoggerAndAddAppender(String loggerName, Level level) {
8181
Configuration cfg = ctx.getConfiguration();
8282
AppenderRef ref = AppenderRef.createAppenderRef(listAppender.getName(), null, null);
8383
AppenderRef[] refs = new AppenderRef[] { ref };
84-
LoggerConfig loggerConfig = LoggerConfig.createLogger(true, level, loggerName, "true", refs, null, cfg, null);
84+
LoggerConfig loggerConfig = LoggerConfig.newBuilder()
85+
.withAdditivity(true)
86+
.withLevel(level)
87+
.withLoggerName(loggerName)
88+
.withIncludeLocation("true")
89+
.withRefs(refs).withConfig(cfg)
90+
.build();
8591
loggerConfig.addAppender(listAppender, level, null);
8692
cfg.addLogger(loggerConfig.getName(), loggerConfig);
8793
}

0 commit comments

Comments
 (0)