changeset 9724:654aaa0d7576 3.2.x

Rely on log4j's default initialization procedure This should make upgrading to Log4j 2.x easier. In passing, use latest Log4j 1.
author Tom Gottfried <tom@intevation.de>
date Fri, 25 Feb 2022 17:13:49 +0100
parents de83690667fe
children da398790fa32
files artifacts/bin/run.sh backend/pom-oracle.xml backend/pom.xml doc/INSTALL_DE docker/Dockerfile.artifacts etl/pom-oracle.xml etl/pom.xml gwt-client/pom.xml gwt-client/src/main/java/org/dive4elements/river/client/server/BaseServletContextListener.java gwt-client/src/main/java/org/dive4elements/river/client/server/CapabilitiesParser.java gwt-client/src/main/java/org/dive4elements/river/client/server/LoggingConfigurator.java gwt-client/src/main/webapp/WEB-INF/classes/log4j.properties gwt-client/src/main/webapp/WEB-INF/log4j.properties gwt-client/src/main/webapp/WEB-INF/web.xml
diffstat 14 files changed, 26 insertions(+), 89 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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>
--- 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>
--- 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
 
--- 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
--- 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>
--- 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>
--- 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>
--- 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);
-    }
 }
--- 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) {
--- 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 :
--- /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
--- 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
--- 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>

http://dive4elements.wald.intevation.org