diff --git a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java index 784d4b90d3..037c08c1c3 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -629,9 +629,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable { @Option( names = {"--logging", "-l"}, paramLabel = "", - description = - "Logging verbosity levels: OFF, FATAL, ERROR, WARN, INFO, DEBUG, TRACE, ALL (default: ${DEFAULT-VALUE})") - private final Level logLevel = LogManager.getRootLogger().getLevel(); + description = "Logging verbosity levels: OFF, FATAL, ERROR, WARN, INFO, DEBUG, TRACE, ALL") + private final Level logLevel = null; @Option( names = {"--miner-enabled"}, @@ -2022,7 +2021,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable { return new BesuExceptionHandler(this::getLogLevel); } - private Level getLogLevel() { + @VisibleForTesting + Level getLogLevel() { return logLevel; } } diff --git a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java index e794940a4c..7f1b51690e 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java @@ -87,6 +87,7 @@ import com.google.common.collect.Lists; import com.google.common.io.Resources; import io.vertx.core.json.JsonObject; import org.apache.commons.text.StringEscapeUtils; +import org.apache.logging.log4j.Level; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.toml.Toml; import org.apache.tuweni.toml.TomlParseResult; @@ -3484,4 +3485,18 @@ public class BesuCommandTest extends CommandTestAbstract { .startsWith("Contents of privacy-public-key-file invalid"); assertThat(commandErrorOutput.toString()).contains("Illegal base64 character"); } + + @Test + public void logLevelHasNullAsDefaultValue() { + final TestBesuCommand command = parseCommand(); + + assertThat(command.getLogLevel()).isNull(); + } + + @Test + public void logLevelIsSetByLoggingOption() { + final TestBesuCommand command = parseCommand("--logging", "WARN"); + + assertThat(command.getLogLevel()).isEqualTo(Level.WARN); + } }