From fdf5b6252f35e9751896520c9a83c6982bca96ec Mon Sep 17 00:00:00 2001 From: Ioan Giurgiu Date: Sun, 25 May 2025 21:52:54 +0000 Subject: [PATCH 1/3] [grid] Silent fail on invalid log level Fixing issue where providing an invalid log level to Grid will fail silently. Since the logger is not yet configured a stacktrace with the exception is printed to console and we continue since the default log level is already configured. Fixes #15790 --- java/src/org/openqa/selenium/grid/log/LoggingOptions.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/java/src/org/openqa/selenium/grid/log/LoggingOptions.java b/java/src/org/openqa/selenium/grid/log/LoggingOptions.java index bbe976f9f105f..27de8b770f75a 100644 --- a/java/src/org/openqa/selenium/grid/log/LoggingOptions.java +++ b/java/src/org/openqa/selenium/grid/log/LoggingOptions.java @@ -76,7 +76,9 @@ public void setLoggingLevel() { try { level = Level.parse(configLevel.toUpperCase(Locale.ROOT)); } catch (IllegalArgumentException e) { - throw new ConfigException("Unable to determine log level from " + configLevel); + // Logger is not configured yet + new ConfigException("Unable to determine log level from " + configLevel + + ". Using default " + DEFAULT_LOG_LEVEL).printStackTrace(); } } From c876dce74cebe7083a46a69fb47a9304794a9c30 Mon Sep 17 00:00:00 2001 From: Ioan Giurgiu Date: Mon, 26 May 2025 10:43:29 +0000 Subject: [PATCH 2/3] [grid] Silent fail on invalid log level Adding link to logging levels as suggested by @diemol and formatting. --- .../org/openqa/selenium/grid/log/LoggingOptions.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/java/src/org/openqa/selenium/grid/log/LoggingOptions.java b/java/src/org/openqa/selenium/grid/log/LoggingOptions.java index 27de8b770f75a..68d748de39afa 100644 --- a/java/src/org/openqa/selenium/grid/log/LoggingOptions.java +++ b/java/src/org/openqa/selenium/grid/log/LoggingOptions.java @@ -77,8 +77,14 @@ public void setLoggingLevel() { level = Level.parse(configLevel.toUpperCase(Locale.ROOT)); } catch (IllegalArgumentException e) { // Logger is not configured yet - new ConfigException("Unable to determine log level from " + configLevel + - ". Using default " + DEFAULT_LOG_LEVEL).printStackTrace(); + new ConfigException( + "Unable to determine log level from " + + configLevel + + ". Using default " + + DEFAULT_LOG_LEVEL + + ". Available log levels can be found at" + + " https://docs.oracle.com/en/java/javase/11/docs/api/java.logging/java/util/logging/Level.html") + .printStackTrace(); } } From d4e3a09ee1ef68e51ac262853c415f5f265a1786 Mon Sep 17 00:00:00 2001 From: Ioan Giurgiu Date: Mon, 26 May 2025 12:55:16 +0000 Subject: [PATCH 3/3] [grid] Silent fail on invalid log level Adding hardcoded log levels as suggested by review. --- .../openqa/selenium/grid/log/LoggingOptions.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/java/src/org/openqa/selenium/grid/log/LoggingOptions.java b/java/src/org/openqa/selenium/grid/log/LoggingOptions.java index 68d748de39afa..2ababcb9fe480 100644 --- a/java/src/org/openqa/selenium/grid/log/LoggingOptions.java +++ b/java/src/org/openqa/selenium/grid/log/LoggingOptions.java @@ -24,6 +24,7 @@ import java.io.UnsupportedEncodingException; import java.util.Arrays; import java.util.Enumeration; +import java.util.List; import java.util.Locale; import java.util.logging.Handler; import java.util.logging.Level; @@ -49,6 +50,17 @@ public class LoggingOptions { private final Config config; private Level level = Level.INFO; public static final String DEFAULT_LOG_TIMESTAMP_FORMAT = "HH:mm:ss.SSS"; + private static final List DEFAULT_LOG_LEVELS = + Arrays.asList( + Level.ALL, + Level.INFO, + Level.CONFIG, + Level.FINE, + Level.FINER, + Level.FINEST, + Level.OFF, + Level.SEVERE, + Level.WARNING); public LoggingOptions(Config config) { this.config = Require.nonNull("Config", config); @@ -82,8 +94,8 @@ public void setLoggingLevel() { + configLevel + ". Using default " + DEFAULT_LOG_LEVEL - + ". Available log levels can be found at" - + " https://docs.oracle.com/en/java/javase/11/docs/api/java.logging/java/util/logging/Level.html") + + ". Available log levels are: " + + DEFAULT_LOG_LEVELS) .printStackTrace(); } }