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

lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git


The following commit(s) were added to refs/heads/master by this push:
     new a8196eb  fix: Update loggers after configuration
a8196eb is described below

commit a8196ebab97151dca4fe25b2fc40ef5d2dc1c571
Author: Christoph Deppisch <cdeppi...@redhat.com>
AuthorDate: Thu Oct 8 19:41:09 2020 +0200

    fix: Update loggers after configuration
    
    Logger configuration needs to be updated so changes come into effect
---
 .../apache/camel/k/main/ApplicationSupport.java    |  2 ++
 .../camel/k/main/ApplicationSupportTest.java       | 42 ++++++++++++++++++++++
 .../src/test/resources/logger.properties           | 18 ++++++++++
 3 files changed, 62 insertions(+)

diff --git 
a/camel-k-main/camel-k-runtime-main/src/main/java/org/apache/camel/k/main/ApplicationSupport.java
 
b/camel-k-main/camel-k-runtime-main/src/main/java/org/apache/camel/k/main/ApplicationSupport.java
index a45703c..288521f 100644
--- 
a/camel-k-main/camel-k-runtime-main/src/main/java/org/apache/camel/k/main/ApplicationSupport.java
+++ 
b/camel-k-main/camel-k-runtime-main/src/main/java/org/apache/camel/k/main/ApplicationSupport.java
@@ -49,5 +49,7 @@ public final class ApplicationSupport {
                 ctx.getConfiguration().addLogger(logger, config);
             }
         );
+
+        ctx.updateLoggers();
     }
 }
diff --git 
a/camel-k-main/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/ApplicationSupportTest.java
 
b/camel-k-main/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/ApplicationSupportTest.java
new file mode 100644
index 0000000..25c5aa0
--- /dev/null
+++ 
b/camel-k-main/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/ApplicationSupportTest.java
@@ -0,0 +1,42 @@
+/*
+ * 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.camel.k.main;
+
+import org.apache.camel.k.Constants;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.slf4j.LoggerFactory;
+
+class ApplicationSupportTest {
+
+    @Test
+    void configureLogging() {
+        System.setProperty(Constants.PROPERTY_CAMEL_K_CONF, 
"src/test/resources/logger.properties");
+
+        try {
+            
Assertions.assertFalse(LoggerFactory.getLogger("org.foo").isDebugEnabled());
+            
Assertions.assertTrue(LoggerFactory.getLogger("org.bar").isInfoEnabled());
+
+            ApplicationSupport.configureLogging();
+
+            
Assertions.assertTrue(LoggerFactory.getLogger("org.foo").isDebugEnabled());
+            
Assertions.assertFalse(LoggerFactory.getLogger("org.bar").isInfoEnabled());
+        } finally {
+            System.getProperties().remove(Constants.PROPERTY_CAMEL_K_CONF);
+        }
+    }
+}
diff --git 
a/camel-k-main/camel-k-runtime-main/src/test/resources/logger.properties 
b/camel-k-main/camel-k-runtime-main/src/test/resources/logger.properties
new file mode 100644
index 0000000..acb9346
--- /dev/null
+++ b/camel-k-main/camel-k-runtime-main/src/test/resources/logger.properties
@@ -0,0 +1,18 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+logging.level.org.foo=DEBUG
+logging.level.org.bar=WARN

Reply via email to