[PATCH 2 of 3] Rely on log4j's default initialization procedure

Wald Commits scm-commit at wald.intevation.org
Fri Feb 25 17:22:29 CET 2022


# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1645805629 -3600
#      Fri Feb 25 17:13:49 2022 +0100
# Branch 3.2.x
# Node ID 654aaa0d7576ea956b23c68b419c239b5cc1f6f7
# Parent  de83690667fe6152822639882ec1a58e7cc60cc4
Rely on log4j's default initialization procedure

This should make upgrading to Log4j 2.x easier.
In passing, use latest Log4j 1.

diff -r de83690667fe -r 654aaa0d7576 artifacts/bin/run.sh
--- a/artifacts/bin/run.sh	Fri Feb 25 14:39:26 2022 +0100
+++ b/artifacts/bin/run.sh	Fri Feb 25 17:13:49 2022 +0100
@@ -21,4 +21,5 @@
      -Dwsplgen.bin.path="$DIR/bin/wsplgen" \
      -Dwsplgen.log.output=false \
      -Dartifact.database.dir="$DIR/conf" \
+     -Dlog4j.configuration="file://$DIR/conf/log4j.properties" \
      $APP
diff -r de83690667fe -r 654aaa0d7576 backend/pom-oracle.xml
--- a/backend/pom-oracle.xml	Fri Feb 25 14:39:26 2022 +0100
+++ b/backend/pom-oracle.xml	Fri Feb 25 17:13:49 2022 +0100
@@ -142,7 +142,7 @@
     <dependency>
       <groupId>log4j</groupId>
       <artifactId>log4j</artifactId>
-      <version>1.2.14</version>
+      <version>1.2.17</version>
     </dependency>
     <dependency>
       <groupId>org.apache.commons</groupId>
diff -r de83690667fe -r 654aaa0d7576 backend/pom.xml
--- a/backend/pom.xml	Fri Feb 25 14:39:26 2022 +0100
+++ b/backend/pom.xml	Fri Feb 25 17:13:49 2022 +0100
@@ -142,7 +142,7 @@
     <dependency>
       <groupId>log4j</groupId>
       <artifactId>log4j</artifactId>
-      <version>1.2.14</version>
+      <version>1.2.17</version>
     </dependency>
     <dependency>
       <groupId>org.apache.commons</groupId>
diff -r de83690667fe -r 654aaa0d7576 doc/INSTALL_DE
--- a/doc/INSTALL_DE	Fri Feb 25 14:39:26 2022 +0100
+++ b/doc/INSTALL_DE	Fri Feb 25 17:13:49 2022 +0100
@@ -137,7 +137,7 @@
 Konfigurieren des Logging
 -------------------------
     # Anpassungen des Loggings können für den Client in
-    # river/gwt-client/src/main/webapp/WEB-INF/log4j.properties
+    # river/gwt-client/src/main/webapp/WEB-INF/classes/log4j.properties
     # und für den Server in river/artifacts/doc/conf/log4j.properties
     # vorgenommen werden
 
diff -r de83690667fe -r 654aaa0d7576 docker/Dockerfile.artifacts
--- a/docker/Dockerfile.artifacts	Fri Feb 25 14:39:26 2022 +0100
+++ b/docker/Dockerfile.artifacts	Fri Feb 25 17:13:49 2022 +0100
@@ -46,6 +46,7 @@
 EXPOSE 8181
 
 CMD mvn -Dexec.mainClass=org.dive4elements.artifactdatabase.App \
+        -Dlog4j.configuration="file:///opt/d4e/river/artifacts/doc/conf/log4j.properties" \
         -Dartifact.database.dir="/opt/d4e/river/artifacts/doc/conf" \
         -Dwsplgen.bin.path="/opt/d4e/river/artifacts/bin/wsplgen" \
         compile exec:java
diff -r de83690667fe -r 654aaa0d7576 etl/pom-oracle.xml
--- a/etl/pom-oracle.xml	Fri Feb 25 14:39:26 2022 +0100
+++ b/etl/pom-oracle.xml	Fri Feb 25 17:13:49 2022 +0100
@@ -36,7 +36,7 @@
     <dependency>
       <groupId>log4j</groupId>
       <artifactId>log4j</artifactId>
-      <version>1.2.14</version>
+      <version>1.2.17</version>
     </dependency>
     <dependency>
       <groupId>org.xerial</groupId>
diff -r de83690667fe -r 654aaa0d7576 etl/pom.xml
--- a/etl/pom.xml	Fri Feb 25 14:39:26 2022 +0100
+++ b/etl/pom.xml	Fri Feb 25 17:13:49 2022 +0100
@@ -36,7 +36,7 @@
     <dependency>
       <groupId>log4j</groupId>
       <artifactId>log4j</artifactId>
-      <version>1.2.14</version>
+      <version>1.2.17</version>
     </dependency>
     <dependency>
       <groupId>org.xerial</groupId>
diff -r de83690667fe -r 654aaa0d7576 gwt-client/pom.xml
--- a/gwt-client/pom.xml	Fri Feb 25 14:39:26 2022 +0100
+++ b/gwt-client/pom.xml	Fri Feb 25 17:13:49 2022 +0100
@@ -101,7 +101,7 @@
     <dependency>
       <groupId>log4j</groupId>
       <artifactId>log4j</artifactId>
-      <version>1.2.14</version>
+      <version>1.2.17</version>
     </dependency>
     <dependency>
       <groupId>org.mapfish.print</groupId>
diff -r de83690667fe -r 654aaa0d7576 gwt-client/src/main/java/org/dive4elements/river/client/server/BaseServletContextListener.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/server/BaseServletContextListener.java	Fri Feb 25 14:39:26 2022 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/server/BaseServletContextListener.java	Fri Feb 25 17:13:49 2022 +0100
@@ -25,8 +25,6 @@
  */
 public class BaseServletContextListener implements ServletContextListener {
 
-    public static final String LOG4J_PROPERTIES = "FLYS_CLIENT_LOG4J_PROPERIES";
-
     public static final Logger log = Logger.getLogger(
         BaseServletContextListener.class);
 
@@ -34,8 +32,6 @@
     public void  contextInitialized(ServletContextEvent sce) {
         ServletContext sc = sce.getServletContext();
 
-        this.initLogging(sc);
-
         String filename = sc.getInitParameter("features-file");
 
         log.debug("Initializing ServletContext");
@@ -52,20 +48,4 @@
     public void contextDestroyed(ServletContextEvent sce) {
         //DO NOTHING
     }
-
-
-    private void initLogging(ServletContext sc) {
-        String log4jProperties = System.getenv(LOG4J_PROPERTIES);
-
-        if (log4jProperties == null || log4jProperties.length() == 0) {
-            String file = sc.getInitParameter("log4j-properties");
-
-            if (file != null && file.length() > 0) {
-                log4jProperties = sc.getRealPath(file);
-            }
-        }
-        System.out.println(log4jProperties);
-
-        LoggingConfigurator.init(log4jProperties);
-    }
 }
diff -r de83690667fe -r 654aaa0d7576 gwt-client/src/main/java/org/dive4elements/river/client/server/CapabilitiesParser.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/server/CapabilitiesParser.java	Fri Feb 25 14:39:26 2022 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/server/CapabilitiesParser.java	Fri Feb 25 17:13:49 2022 +0100
@@ -112,10 +112,6 @@
     public static void main(String[] args) {
         log.info("Do static Capabilities request/parsing.");
 
-        String log4jProperties = System.getenv(
-            BaseServletContextListener.LOG4J_PROPERTIES);
-        LoggingConfigurator.init(log4jProperties);
-
         try {
             String wmsURL = System.getProperty("test.wms");
             if (wmsURL == null || args.length > 0) {
diff -r de83690667fe -r 654aaa0d7576 gwt-client/src/main/java/org/dive4elements/river/client/server/LoggingConfigurator.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/server/LoggingConfigurator.java	Fri Feb 25 14:39:26 2022 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
- * Software engineering by Intevation GmbH
- *
- * This file is Free Software under the GNU AGPL (>=v3)
- * and comes with ABSOLUTELY NO WARRANTY! Check out the
- * documentation coming with Dive4Elements River for details.
- */
-
-package org.dive4elements.river.client.server;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.PropertyConfigurator;
-
-
-public class LoggingConfigurator {
-
-    private static final Logger log =
-        Logger.getLogger(LoggingConfigurator.class);
-
-
-    private LoggingConfigurator() {
-    }
-
-    public static void init(String log4jProperties) {
-        if (log4jProperties != null && log4jProperties.length() > 0) {
-            PropertyConfigurator.configure(log4jProperties);
-            log.info("Log4J logging initialized.");
-        }
-        else {
-            System.out.println("Error while setting up Log4J configuration.");
-        }
-
-        System.out.println("LoggingConfigurator.init finished");
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r de83690667fe -r 654aaa0d7576 gwt-client/src/main/webapp/WEB-INF/classes/log4j.properties
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gwt-client/src/main/webapp/WEB-INF/classes/log4j.properties	Fri Feb 25 17:13:49 2022 +0100
@@ -0,0 +1,18 @@
+log4j.rootLogger=DEBUG, FLYS
+
+########## INTERNAL PACKAGES
+log4j.category.de.intevation.flys.client.server=DEBUG
+
+
+########## EXTERNAL PACKAGES
+log4j.category.org.apache.http=ERROR
+log4j.category.de.intevation.artifacts.httpclient=WARN
+
+########## APPENDER SETTINGS
+log4j.appender.FLYS.layout=org.apache.log4j.PatternLayout
+log4j.appender.FLYS.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
+
+log4j.appender.FLYS=org.apache.log4j.RollingFileAppender
+log4j.appender.FLYS.File=/var/log/d4e-river/d4e-client.log
+log4j.appender.FLYS.MaxFileSize=5000KB
+log4j.appender.FLYS.MaxBackupIndex=3
diff -r de83690667fe -r 654aaa0d7576 gwt-client/src/main/webapp/WEB-INF/log4j.properties
--- a/gwt-client/src/main/webapp/WEB-INF/log4j.properties	Fri Feb 25 14:39:26 2022 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-log4j.rootLogger=DEBUG, FLYS
-
-########## INTERNAL PACKAGES
-log4j.category.de.intevation.flys.client.server=DEBUG
-
-
-########## EXTERNAL PACKAGES
-log4j.category.org.apache.http=ERROR
-log4j.category.de.intevation.artifacts.httpclient=WARN
-
-########## APPENDER SETTINGS
-log4j.appender.FLYS.layout=org.apache.log4j.PatternLayout
-log4j.appender.FLYS.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
-
-log4j.appender.FLYS=org.apache.log4j.RollingFileAppender
-log4j.appender.FLYS.File=/var/log/d4e-river/d4e-client.log
-log4j.appender.FLYS.MaxFileSize=5000KB
-log4j.appender.FLYS.MaxBackupIndex=3
diff -r de83690667fe -r 654aaa0d7576 gwt-client/src/main/webapp/WEB-INF/web.xml
--- a/gwt-client/src/main/webapp/WEB-INF/web.xml	Fri Feb 25 14:39:26 2022 +0100
+++ b/gwt-client/src/main/webapp/WEB-INF/web.xml	Fri Feb 25 17:13:49 2022 +0100
@@ -64,11 +64,6 @@
         <param-value>/WEB-INF/features.xml</param-value>
     </context-param>
 
-    <context-param>
-        <param-name>log4j-properties</param-name>
-        <param-value>/WEB-INF/log4j.properties</param-value>
-    </context-param>
-
     <listener>
         <listener-class>org.dive4elements.river.client.server.BaseServletContextListener</listener-class>
     </listener>


More information about the Dive4Elements-commits mailing list