Skip to content

Commit

Permalink
Fix LogManager logger call chain
Browse files Browse the repository at this point in the history
  • Loading branch information
jkschneider committed Apr 7, 2024
1 parent 6fbfc31 commit f1e73b8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/openrewrite/java/logging/AddLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static AddLogger addSlf4jLogger(J.ClassDeclaration scope, String loggerNa
public static AddLogger addJulLogger(J.ClassDeclaration scope, String loggerName, @SuppressWarnings("unused") ExecutionContext ctx) {
return new AddLogger(scope, "java.util.logging.Logger", "java.util.logging.LogManager", loggerName, visitor ->
JavaTemplate
.builder("private static final Logger #{} = LogManager.getLogger(\"#{}\");")
.builder("private static final Logger #{} = LogManager.getLogManager().getLogger(\"#{}\");")
.contextSensitive()
.imports("java.util.logging.Logger", "java.util.logging.LogManager")
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void bar() {
import java.util.logging.Logger;
class Foo {
private static final Logger log = LogManager.getLogger("Foo");
private static final Logger log = LogManager.getLogManager().getLogger("Foo");
void bar() {
log.log(Level.INFO, "Test");
Expand Down

0 comments on commit f1e73b8

Please sign in to comment.