elharo commented on code in PR #2042:
URL: https://github.com/apache/maven/pull/2042#discussion_r1913269974


##########
impl/maven-cli/src/main/java/org/apache/maven/cling/logging/impl/MavenSimpleConfiguration.java:
##########
@@ -37,7 +40,16 @@ public void setRootLoggerLevel(Level level) {
                     case INFO -> "info";
                     default -> "error";
                 };
-        System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", value);
+
+        String defaultLogLevelKey = "org.slf4j.simpleLogger.defaultLogLevel";
+        String current = System.getProperty(defaultLogLevelKey);
+        if (current == null) {
+            System.setProperty(defaultLogLevelKey, value);
+        } else {

Review Comment:
   I'm not sure I follow. Can you rephrase?



##########
impl/maven-cli/src/main/java/org/apache/maven/cling/logging/impl/MavenSimpleConfiguration.java:
##########
@@ -37,7 +40,17 @@ public void setRootLoggerLevel(Level level) {
                     case INFO -> "info";
                     default -> "error";
                 };
-        System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", value);
+
+        String defaultLogLevelKey = "org.slf4j.simpleLogger.defaultLogLevel";
+        String current = System.getProperty(defaultLogLevelKey);
+        if (current == null) {
+            System.setProperty(defaultLogLevelKey, value);
+        } else {
+            LOGGER.warn(
+                    "System property '{}' is already set to '{}' - ignoring 
log level from -X/-e/-q options",

Review Comment:
   should we specify what the log level that's being ignored is? that is, add a 
third parameter?
   
   Also, it's really easy to mix parameters up. Simple string concatenation is 
preferable.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to