You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2022/05/15 22:16:18 UTC

[logging-log4j2] branch release-2.x updated (26efbc801b -> 918bb8472d)

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

rgoers pushed a change to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git


    from 26efbc801b LOG4J2-3493 - ClassArbiter mistakenly used SystemPropertyArbiter.Builder
     new 25fff83746 LOG4J2-3506 - Support Spring 2.6.x
     new 918bb8472d LOG4J2-3506 - Support Spring 2.6.x

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../boot/Log4j2CloudConfigLoggingSystem.java       | 63 +++++++++++++++++-----
 pom.xml                                            |  4 +-
 src/changes/changes.xml                            |  7 +--
 3 files changed, 56 insertions(+), 18 deletions(-)


[logging-log4j2] 02/02: LOG4J2-3506 - Support Spring 2.6.x

Posted by rg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rgoers pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 918bb8472d0b20c3a061243d2a8070535407f075
Author: Ralph Goers <rg...@apache.org>
AuthorDate: Sun May 15 15:16:05 2022 -0700

    LOG4J2-3506 - Support Spring 2.6.x
---
 src/changes/changes.xml | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 283a95ed72..4b53318fa9 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -30,7 +30,9 @@
          - "remove" - Removed
     -->
     <release version="2.18.0" date="2022-TBD" description="GA Release 2.18.0">
-      <!-- FIXES -->
+      <action issue="LOG4J2-3506" dev="rgoers" type="update">
+        Support Spring 2.6.x.
+      </action>
       <action issue="LOG4J2-3493" dev="rgoers" type="fix" due-to="Dmytro Voloshyn">
         ClassArbiter's newBuilder method referenced the wrong class.
       </action>
@@ -124,9 +126,8 @@
       <action issue="LOG4J2-3362" dev="pkarwasz" type="add">
         Add support for Jakarta Mail API in the SMTP appender.
       </action>
-      <!-- UPDATES -->
       <action issue="LOG4J2-3428" dev="ggregory" type="fix" due-to="LF-Lin">
-        Update 3rd party dependencies for 2.17.3.
+        Update 3rd party dependencies for 2.18.0.
       </action>
     </release>
     <release version="2.17.2" date="2022-02-23" description="GA Release 2.17.2">


[logging-log4j2] 01/02: LOG4J2-3506 - Support Spring 2.6.x

Posted by rg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rgoers pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 25fff83746dceabe38aaa026804de8eeb6a161a6
Author: Ralph Goers <rg...@apache.org>
AuthorDate: Sun May 15 15:13:35 2022 -0700

    LOG4J2-3506 - Support Spring 2.6.x
---
 .../boot/Log4j2CloudConfigLoggingSystem.java       | 63 +++++++++++++++++-----
 pom.xml                                            |  4 +-
 2 files changed, 52 insertions(+), 15 deletions(-)

diff --git a/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/Log4j2CloudConfigLoggingSystem.java b/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/Log4j2CloudConfigLoggingSystem.java
index badd9a4c24..5186579d70 100644
--- a/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/Log4j2CloudConfigLoggingSystem.java
+++ b/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/Log4j2CloudConfigLoggingSystem.java
@@ -27,6 +27,7 @@ import java.net.URLConnection;
 import java.net.URLDecoder;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 import java.util.Properties;
 import javax.net.ssl.HttpsURLConnection;
@@ -44,9 +45,13 @@ import org.apache.logging.log4j.core.net.ssl.SslConfiguration;
 import org.apache.logging.log4j.core.net.ssl.SslConfigurationFactory;
 import org.apache.logging.log4j.core.util.AuthorizationProvider;
 import org.apache.logging.log4j.core.util.FileUtils;
+import org.apache.logging.log4j.internal.LogManagerStatus;
 import org.apache.logging.log4j.status.StatusLogger;
 import org.apache.logging.log4j.util.PropertiesUtil;
 import org.apache.logging.log4j.util.Strings;
+import org.springframework.boot.context.properties.bind.BindResult;
+import org.springframework.boot.context.properties.bind.Bindable;
+import org.springframework.boot.context.properties.bind.Binder;
 import org.springframework.boot.logging.LogFile;
 import org.springframework.boot.logging.LoggingInitializationContext;
 import org.springframework.boot.logging.LoggingSystem;
@@ -121,13 +126,35 @@ public class Log4j2CloudConfigLoggingSystem extends Log4J2LoggingSystem {
         return defaultPath;
     }
 
+    /**
+     * This method is removed from Spring in 3.x and is scheduled to be removed in 2.8.x. It must be left in
+     * to support older Spring releases.
+     * @param location the location
+     * @param logFile log file configuration
+     */
     @Override
     protected void loadConfiguration(String location, LogFile logFile) {
+        loadConfiguration(location, logFile, Collections.emptyList());
+    }
+
+    /**
+     * Added in Spring 2.6.0, the overrides parameter allows override files to be specified in the
+     * "logging.log4j2.config.override" property. However, spring does not support passing credentials
+     * when accessing the location. We do.
+     * @param location The location of the primary configuration.
+     * @param logFile log file configuration.
+     * @param overrides Any override files.
+     */
+    @Override
+    protected void loadConfiguration(String location, LogFile logFile, List<String> overrides) {
         Assert.notNull(location, "Location must not be null");
         try {
             LoggerContext ctx = getLoggerContext();
-            String[] locations = parseConfigLocations(location);
-            if (locations.length == 1) {
+            List<String> locations = parseConfigLocations(location);
+            if (overrides != null) {
+                locations.addAll(overrides);
+            }
+            if (locations.size() == 1) {
                 final URL url = ResourceUtils.getURL(location);
                 final ConfigurationSource source = getConfigurationSource(url);
                 if (source != null) {
@@ -135,17 +162,27 @@ public class Log4j2CloudConfigLoggingSystem extends Log4J2LoggingSystem {
                 }
             } else {
                 final List<AbstractConfiguration> configs = new ArrayList<>();
+                boolean first = true;
                 for (final String sourceLocation : locations) {
                     final ConfigurationSource source = getConfigurationSource(ResourceUtils.getURL(sourceLocation));
                     if (source != null) {
-                        final Configuration config = ConfigurationFactory.getInstance().getConfiguration(ctx, source);
-                        if (config instanceof AbstractConfiguration) {
-                            configs.add((AbstractConfiguration) config);
-                        } else {
-                            LOGGER.warn("Configuration at {} cannot be combined in a CompositeConfiguration", sourceLocation);
-                            return;
+                        try {
+                            final Configuration config = ConfigurationFactory.getInstance().getConfiguration(ctx, source);
+                            if (config instanceof AbstractConfiguration) {
+                                configs.add((AbstractConfiguration) config);
+                            } else {
+                                LOGGER.warn("Configuration at {} cannot be combined in a CompositeConfiguration", sourceLocation);
+                                return;
+                            }
+                        } catch (Exception ex) {
+                            if (!first) {
+                                LOGGER.warn("Error accessing {}: {}. Ignoring override", sourceLocation, ex.getMessage());
+                            } else {
+                                throw ex;
+                            }
                         }
                     }
+                    first = false;
                 }
                 if (configs.size() > 1) {
                     ctx.start(new CompositeConfiguration(configs));
@@ -156,7 +193,7 @@ public class Log4j2CloudConfigLoggingSystem extends Log4J2LoggingSystem {
         }
         catch (Exception ex) {
             throw new IllegalStateException(
-                "Could not initialize Log4J2 logging from " + location, ex);
+                    "Could not initialize Log4J2 logging from " + location, ex);
         }
     }
 
@@ -166,11 +203,11 @@ public class Log4j2CloudConfigLoggingSystem extends Log4J2LoggingSystem {
         super.cleanUp();
     }
 
-    private String[] parseConfigLocations(String configLocations) {
+    private List<String> parseConfigLocations(String configLocations) {
         final String[] uris = configLocations.split("\\?");
         final List<String> locations = new ArrayList<>();
+        locations.add(uris[0]);
         if (uris.length > 1) {
-            locations.add(uris[0]);
             try {
                 final URL url = new URL(configLocations);
                 final String[] pairs = url.getQuery().split("&");
@@ -185,12 +222,12 @@ public class Log4j2CloudConfigLoggingSystem extends Log4J2LoggingSystem {
                         LOGGER.warn("Bad data in configuration string: {}", pair);
                     }
                 }
-                return locations.toArray(Strings.EMPTY_ARRAY);
+                return locations;
             } catch (MalformedURLException ex) {
                 LOGGER.warn("Unable to parse configuration URL {}", configLocations);
             }
         }
-        return new String[] {uris[0]};
+        return locations;
     }
 
     private ConfigurationSource getConfigurationSource(URL url) throws IOException, URISyntaxException {
diff --git a/pom.xml b/pom.xml
index 1683a6a154..3d7ab8af7c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -240,8 +240,8 @@
     <logbackVersion>1.2.11</logbackVersion>
     <jackson1Version>1.9.13</jackson1Version>
     <jackson2Version>2.13.2</jackson2Version>
-    <spring-boot.version>2.5.7</spring-boot.version>
-    <springVersion>5.3.17</springVersion>
+    <spring-boot.version>2.6.7</spring-boot.version>
+    <springVersion>5.3.19</springVersion>
     <kubernetes-client.version>5.12.1</kubernetes-client.version>
     <flumeVersion>1.9.0</flumeVersion>
     <disruptorVersion>3.4.4</disruptorVersion>