This is an automated email from the ASF dual-hosted git repository.

hansva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git


The following commit(s) were added to refs/heads/main by this push:
     new f68cb94e19 Allow setting HOP_DISABLE_CONSOLE_LOGGING via env variable, 
fixes #5188 (#7015)
f68cb94e19 is described below

commit f68cb94e196285d0b9694b39c7580ac35a51b259
Author: Hans Van Akelyen <[email protected]>
AuthorDate: Fri Apr 17 14:40:22 2026 +0200

    Allow setting HOP_DISABLE_CONSOLE_LOGGING via env variable, fixes #5188 
(#7015)
---
 .../org/apache/hop/core/HopClientEnvironment.java  |  5 +-
 .../hop/core/config/HopResolvedSettings.java       | 70 ++++++++++++++++++++++
 2 files changed, 74 insertions(+), 1 deletion(-)

diff --git a/core/src/main/java/org/apache/hop/core/HopClientEnvironment.java 
b/core/src/main/java/org/apache/hop/core/HopClientEnvironment.java
index 9d7b149c60..fdf358bf67 100644
--- a/core/src/main/java/org/apache/hop/core/HopClientEnvironment.java
+++ b/core/src/main/java/org/apache/hop/core/HopClientEnvironment.java
@@ -23,6 +23,7 @@ import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+import org.apache.hop.core.config.HopResolvedSettings;
 import org.apache.hop.core.database.DatabasePluginType;
 import org.apache.hop.core.encryption.Encr;
 import org.apache.hop.core.encryption.TwoWayPasswordEncoderPluginType;
@@ -103,7 +104,9 @@ public class HopClientEnvironment {
 
     // Add console output so that folks see what's going on...
     //
-    if 
(!"Y".equalsIgnoreCase(System.getProperty(Const.HOP_DISABLE_CONSOLE_LOGGING, 
"N"))) {
+    String disableConsoleLogging =
+        HopResolvedSettings.resolveString(Const.HOP_DISABLE_CONSOLE_LOGGING, 
"N");
+    if (!"Y".equalsIgnoreCase(disableConsoleLogging)) {
       HopLogStore.getAppender().addLoggingEventListener(new 
ConsoleLoggingEventListener());
     }
     HopLogStore.getAppender().addLoggingEventListener(new 
Slf4jLoggingEventListener());
diff --git 
a/core/src/main/java/org/apache/hop/core/config/HopResolvedSettings.java 
b/core/src/main/java/org/apache/hop/core/config/HopResolvedSettings.java
new file mode 100644
index 0000000000..9e16e89316
--- /dev/null
+++ b/core/src/main/java/org/apache/hop/core/config/HopResolvedSettings.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.core.config;
+
+import java.util.Map;
+import org.apache.hop.core.Const;
+
+/**
+ * Resolves Hop settings from layered configuration so callers can treat 
{@code hop-config.json},
+ * the process environment, and the JVM consistently.
+ *
+ * <p><b>Precedence</b> (each layer replaces the previous when that layer 
defines the name; the last
+ * applicable layer wins):
+ *
+ * <ol>
+ *   <li>{@code hop-config.json} described variables &mdash; defaults shipped 
with the app or image
+ *   <li>{@linkplain System#getenv(String) Environment variables} &mdash; 
overrides from Docker,
+ *       Kubernetes, CI/CD, or the shell ({@code containsKey} on the 
environment map)
+ *   <li>Java {@linkplain System#getProperty(String) system properties} 
&mdash; explicit runtime
+ *       overrides such as {@code -Dname=value} ({@code containsKey} on {@link
+ *       System#getProperties()})
+ * </ol>
+ *
+ * <p>This ordering matches a common operations pattern: bake stable defaults 
into the image or
+ * config file, let the platform inject environment at deploy time, and 
reserve {@code -D} for
+ * ad-hoc or debugging overrides that should win over everything else.
+ *
+ * <p><b>Note:</b> After full Hop environment initialization, described 
variables from {@code
+ * hop-config.json} are copied into {@link System#setProperty(String, 
String)}. For names that
+ * appear in the config file, {@link System#getProperties()} will then usually 
repeat the file
+ * value, so the JVM tier can override environment variables until that copy 
is aligned with this
+ * resolver. Call sites that run <em>before</em> that copy (for example {@link
+ * org.apache.hop.core.HopClientEnvironment}) see the intended hop → env → 
{@code -D} behavior.
+ */
+public final class HopResolvedSettings {
+
+  private HopResolvedSettings() {}
+
+  /**
+   * @param name setting / variable name (for example {@link 
Const#HOP_DISABLE_CONSOLE_LOGGING})
+   * @param defaultValue used when no layer supplies a value
+   * @return the effective string value
+   */
+  public static String resolveString(String name, String defaultValue) {
+    String value = HopConfig.readStringVariable(name, null);
+    Map<String, String> env = System.getenv();
+    if (env.containsKey(name)) {
+      value = env.get(name);
+    }
+    if (System.getProperties().containsKey(name)) {
+      value = System.getProperty(name);
+    }
+    return Const.NVL(value, defaultValue);
+  }
+}

Reply via email to