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

bchapuis pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-baremaps.git


The following commit(s) were added to refs/heads/main by this push:
     new aafbfabe Consolidate logging dependencies (#738)
aafbfabe is described below

commit aafbfabe25dc16ded7bd9e01c45e10009e7b9130
Author: Perdjesk <[email protected]>
AuthorDate: Wed Aug 2 09:21:05 2023 +0200

    Consolidate logging dependencies (#738)
---
 baremaps-cli/pom.xml                               | 12 ++++++++
 .../java/org/apache/baremaps/cli/Baremaps.java     | 32 ++++++----------------
 baremaps-core/pom.xml                              |  8 ------
 baremaps-ogcapi/pom.xml                            |  8 ------
 pom.xml                                            | 28 +++++++++++++------
 5 files changed, 40 insertions(+), 48 deletions(-)

diff --git a/baremaps-cli/pom.xml b/baremaps-cli/pom.xml
index 410f68af..4e7efbe7 100644
--- a/baremaps-cli/pom.xml
+++ b/baremaps-cli/pom.xml
@@ -59,6 +59,18 @@
       <groupId>org.apache.baremaps</groupId>
       <artifactId>baremaps-server</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-jul</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.apache.logging.log4j</groupId>
       <artifactId>log4j-slf4j2-impl</artifactId>
diff --git a/baremaps-cli/src/main/java/org/apache/baremaps/cli/Baremaps.java 
b/baremaps-cli/src/main/java/org/apache/baremaps/cli/Baremaps.java
index d60e5bd5..28628bfa 100644
--- a/baremaps-cli/src/main/java/org/apache/baremaps/cli/Baremaps.java
+++ b/baremaps-cli/src/main/java/org/apache/baremaps/cli/Baremaps.java
@@ -26,11 +26,7 @@ import org.apache.baremaps.cli.map.Map;
 import org.apache.baremaps.cli.ogcapi.OgcApi;
 import org.apache.baremaps.cli.workflow.Workflow;
 import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.LoggerConfig;
-import org.slf4j.bridge.SLF4JBridgeHandler;
+import org.apache.logging.log4j.core.config.Configurator;
 import picocli.CommandLine;
 import picocli.CommandLine.Command;
 import picocli.CommandLine.IVersionProvider;
@@ -42,22 +38,9 @@ import picocli.CommandLine.Option;
     sortOptions = false)
 public class Baremaps implements Callable<Integer> {
 
-  static {
-    // Apache SIS uses java.util.logging, therefore, we need to remove
-    // the existing handlers and to replace them with a bridge to slf4j.
-    SLF4JBridgeHandler.removeHandlersForRootLogger();
-    SLF4JBridgeHandler.install();
-  }
-
   @Option(names = {"-V", "--version"}, versionHelp = true, description = 
"Print version info.")
   boolean version;
 
-  @Override
-  public Integer call() {
-    CommandLine.usage(this, System.out);
-    return 0;
-  }
-
   public static void main(String... args) {
     // Set the log level
     for (int i = 0; i < args.length; i++) {
@@ -69,11 +52,7 @@ public class Baremaps implements Callable<Integer> {
         level = arg.substring(12).strip();
       }
       if (!"".equals(level)) {
-        LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
-        Configuration config = ctx.getConfiguration();
-        LoggerConfig loggerConfig = 
config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
-        loggerConfig.setLevel(Level.getLevel(level));
-        ctx.updateLoggers();
+        Configurator.setRootLevel(Level.getLevel(level));
       }
     }
 
@@ -83,6 +62,13 @@ public class Baremaps implements Callable<Integer> {
     cmd.execute(args);
   }
 
+  @Override
+  public Integer call() {
+    CommandLine.usage(this, System.out);
+    return 0;
+  }
+
+
   static class VersionProvider implements IVersionProvider {
 
     public String[] getVersion() throws Exception {
diff --git a/baremaps-core/pom.xml b/baremaps-core/pom.xml
index 1bc65934..ed5961a0 100644
--- a/baremaps-core/pom.xml
+++ b/baremaps-core/pom.xml
@@ -89,10 +89,6 @@
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-compress</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.apache.logging.log4j</groupId>
-      <artifactId>log4j-slf4j2-impl</artifactId>
-    </dependency>
     <dependency>
       <groupId>org.apache.lucene</groupId>
       <artifactId>lucene-core</artifactId>
@@ -134,10 +130,6 @@
       <groupId>org.postgresql</groupId>
       <artifactId>postgresql</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>jul-to-slf4j</artifactId>
-    </dependency>
     <dependency>
       <groupId>org.wololo</groupId>
       <artifactId>flatgeobuf</artifactId>
diff --git a/baremaps-ogcapi/pom.xml b/baremaps-ogcapi/pom.xml
index 39fa99ac..70ace7ef 100644
--- a/baremaps-ogcapi/pom.xml
+++ b/baremaps-ogcapi/pom.xml
@@ -59,10 +59,6 @@
       <groupId>org.apache.baremaps</groupId>
       <artifactId>baremaps-core</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.apache.logging.log4j</groupId>
-      <artifactId>log4j-slf4j2-impl</artifactId>
-    </dependency>
     <dependency>
       <groupId>org.glassfish.jaxb</groupId>
       <artifactId>jaxb-runtime</artifactId>
@@ -103,10 +99,6 @@
       <groupId>org.postgresql</groupId>
       <artifactId>postgresql</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-api</artifactId>
-    </dependency>
   </dependencies>
 
   <build>
diff --git a/pom.xml b/pom.xml
index fa029f47..ff4cbe14 100644
--- a/pom.xml
+++ b/pom.xml
@@ -98,7 +98,7 @@
     <version.lib.jts>1.19.0</version.lib.jts>
     <version.lib.junit>5.7.1</version.lib.junit>
     <version.lib.junit-vintage>5.7.2</version.lib.junit-vintage>
-    <version.lib.log4j>2.19.0</version.lib.log4j>
+    <version.lib.log4j>2.20.0</version.lib.log4j>
     <version.lib.pgbulkinsert>8.1.0</version.lib.pgbulkinsert>
     <version.lib.picocli>4.6.3</version.lib.picocli>
     <version.lib.postgresql>42.5.0</version.lib.postgresql>
@@ -107,7 +107,7 @@
     <version.lib.roaringbitmap>0.9.38</version.lib.roaringbitmap>
     <version.lib.servicetalk>0.42.28</version.lib.servicetalk>
     <version.lib.servlet>3.1.0</version.lib.servlet>
-    <version.lib.slf4j>2.0.3</version.lib.slf4j>
+    <version.lib.slf4j>2.0.7</version.lib.slf4j>
     <version.lib.sqlite>3.39.3.0</version.lib.sqlite>
     <version.lib.swagger-parser>2.1.13</version.lib.swagger-parser>
     <version.lib.testcontainers>1.17.3</version.lib.testcontainers>
@@ -340,10 +340,17 @@
         <artifactId>log4j-core</artifactId>
         <version>${version.lib.log4j}</version>
       </dependency>
+      <dependency>
+        <groupId>org.apache.logging.log4j</groupId>
+        <artifactId>log4j-jul</artifactId>
+        <version>${version.lib.log4j}</version>
+        <scope>runtime</scope>
+      </dependency>
       <dependency>
         <groupId>org.apache.logging.log4j</groupId>
         <artifactId>log4j-slf4j2-impl</artifactId>
         <version>${version.lib.log4j}</version>
+        <scope>runtime</scope>
       </dependency>
       <dependency>
         <groupId>org.apache.lucene</groupId>
@@ -468,11 +475,6 @@
         <artifactId>RoaringBitmap</artifactId>
         <version>${version.lib.roaringbitmap}</version>
       </dependency>
-      <dependency>
-        <groupId>org.slf4j</groupId>
-        <artifactId>jul-to-slf4j</artifactId>
-        <version>${version.lib.slf4j}</version>
-      </dependency>
       <dependency>
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-api</artifactId>
@@ -531,13 +533,21 @@
       <groupId>com.fasterxml.jackson.datatype</groupId>
       <artifactId>jackson-datatype-jdk8</artifactId>
     </dependency>
+    <!-- Provide logging for any child module during test -->
     <dependency>
       <groupId>org.apache.logging.log4j</groupId>
-      <artifactId>log4j-api</artifactId>
+      <artifactId>log4j-core</artifactId>
+      <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.logging.log4j</groupId>
-      <artifactId>log4j-core</artifactId>
+      <artifactId>log4j-jul</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j2-impl</artifactId>
+      <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>org.awaitility</groupId>

Reply via email to