changeset 124:7261c948425c 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 15:15:04 +0100
parents ddbb7256246f
children e602a29f1dcc
files README bin/run.sh pom.xml src/main/java/org/dive4elements/artifacts/httpclient/ConsoleClient.java
diffstat 4 files changed, 6 insertions(+), 50 deletions(-) [+]
line wrap: on
line diff
--- a/README	Mon Mar 22 12:41:23 2021 +0100
+++ b/README	Fri Feb 25 15:15:04 2022 +0100
@@ -1,18 +1,8 @@
-============
-DEPENDENCIES
-============
-
-- JUnit 3.8.1
-- Log4j 1.2.14
-- Restlet 2.0-SNAPSHOT
-- Restlet-XML 2.0-SNAPSHOT
-
-
 ============================
 COMPILATION AND INSTALLATION
 ============================
 
-This project is based on maven2. To compile/install this client, just do:
+This project is based on Maven. To compile/install this client, just do:
 
     mvn compile package
 
@@ -41,7 +31,7 @@
 RUNNING THE CLIENT
 ==================
 
-There is a bash script in the ``contrib`` directory. This might be used to
+There is a bash script that might be used to
 start the console based client. Note, that you need the jars of the depending
 libraries in the ``target`` directory.
 
--- a/bin/run.sh	Mon Mar 22 12:41:23 2021 +0100
+++ b/bin/run.sh	Fri Feb 25 15:15:04 2022 +0100
@@ -14,5 +14,6 @@
      -Djava.io.tmpdir="$DIR/cache" \
      -Dconfig.dir="$DIR/conf" \
      -Dconfig.file="demo-config.conf" \
-     de.intevation.bsh.consoleclient.ConsoleClient \
+     -Dlog4j.configuration="file://$DIR/conf/log4j.properties" \
+     org.dive4elements.artifacts.httpclient.ConsoleClient \
      2>&1 > /dev/null
--- a/pom.xml	Mon Mar 22 12:41:23 2021 +0100
+++ b/pom.xml	Fri Feb 25 15:15:04 2022 +0100
@@ -46,7 +46,7 @@
     <dependency>
       <groupId>log4j</groupId>
       <artifactId>log4j</artifactId>
-      <version>1.2.14</version>
+      <version>1.2.17</version>
     </dependency>
     <dependency>
       <groupId>org.restlet.jse</groupId>
--- a/src/main/java/org/dive4elements/artifacts/httpclient/ConsoleClient.java	Mon Mar 22 12:41:23 2021 +0100
+++ b/src/main/java/org/dive4elements/artifacts/httpclient/ConsoleClient.java	Fri Feb 25 15:15:04 2022 +0100
@@ -13,8 +13,6 @@
 import java.io.FileOutputStream;
 import java.io.OutputStream;
 
-import java.net.MalformedURLException;
-
 import java.util.Arrays;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -28,7 +26,6 @@
 import org.w3c.dom.NodeList;
 
 import org.apache.log4j.Logger;
-import org.apache.log4j.PropertyConfigurator;
 
 import org.dive4elements.artifacts.httpclient.http.HttpClient;
 import org.dive4elements.artifacts.httpclient.http.HttpClientImpl;
@@ -48,13 +45,6 @@
 public class ConsoleClient
 {
     /**
-     * The logging is done via Log4j. To configure the logging
-     * a file 'log4j.properties' is search in the configuration directory.
-     */
-    public static final String LOG4J_PROPERTIES = "log4j.properties";
-
-
-    /**
      * The path of the configuration directory.
      */
     public static final String CONFIG_PATH = System.getProperty("config.dir",
@@ -69,32 +59,7 @@
     /**
      * The logger used in this class.
      */
-    private static Logger logger;
-
-
-    static {
-        configureLogging();
-
-        logger = Logger.getLogger(ConsoleClient.class);
-    }
-
-
-    /**
-     * Trys to load the Log4j configuration from ${config.dir}/log4j.properties.
-     */
-    public static final void configureLogging() {
-        File configDir = new File(CONFIG_PATH);
-        File propFile  = new File(configDir, LOG4J_PROPERTIES);
-
-        if (propFile.isFile() && propFile.canRead()) {
-            try {
-                PropertyConfigurator.configure(propFile.toURI().toURL());
-            }
-            catch (MalformedURLException mue) {
-                mue.printStackTrace(System.err);
-            }
-        }
-    }
+    private static Logger logger = Logger.getLogger(ConsoleClient.class);
 
 
     public static final Configuration readConfiguration() {

http://dive4elements.wald.intevation.org