changeset 125:e602a29f1dcc 3.2.x tip

Upgrade to Log4j 2
author Tom Gottfried <tom@intevation.de>
date Mon, 28 Feb 2022 17:49:46 +0100
parents 7261c948425c
children
files bin/run.sh conf/log4j.properties pom.xml src/main/java/org/dive4elements/artifacts/httpclient/ConsoleClient.java src/main/java/org/dive4elements/artifacts/httpclient/http/HttpClientImpl.java src/main/java/org/dive4elements/artifacts/httpclient/utils/ArtifactProtocolUtils.java src/main/java/org/dive4elements/artifacts/httpclient/utils/Configuration.java src/main/java/org/dive4elements/artifacts/httpclient/utils/XMLUtils.java
diffstat 8 files changed, 24 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/bin/run.sh	Fri Feb 25 15:15:04 2022 +0100
+++ b/bin/run.sh	Mon Feb 28 17:49:46 2022 +0100
@@ -14,6 +14,5 @@
      -Djava.io.tmpdir="$DIR/cache" \
      -Dconfig.dir="$DIR/conf" \
      -Dconfig.file="demo-config.conf" \
-     -Dlog4j.configuration="file://$DIR/conf/log4j.properties" \
      org.dive4elements.artifacts.httpclient.ConsoleClient \
      2>&1 > /dev/null
--- a/conf/log4j.properties	Fri Feb 25 15:15:04 2022 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-#### Log just errors and warnings to a file.
-log4j.rootLogger=DEBUG, BSH
-
-log4j.appender.BSH=org.apache.log4j.RollingFileAppender
-log4j.appender.BSH.File=./logs/console-client.log
-log4j.appender.BSH.MaxFileSize=5000KB
-log4j.appender.BSH.MaxBackupIndex=1
-log4j.appender.BSH.layout=org.apache.log4j.PatternLayout
-log4j.appender.BSH.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
--- a/pom.xml	Fri Feb 25 15:15:04 2022 +0100
+++ b/pom.xml	Mon Feb 28 17:49:46 2022 +0100
@@ -44,9 +44,15 @@
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>log4j</groupId>
-      <artifactId>log4j</artifactId>
-      <version>1.2.17</version>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+      <version>2.17.1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <version>2.17.1</version>
+      <scope>runtime</scope>
     </dependency>
     <dependency>
       <groupId>org.restlet.jse</groupId>
--- a/src/main/java/org/dive4elements/artifacts/httpclient/ConsoleClient.java	Fri Feb 25 15:15:04 2022 +0100
+++ b/src/main/java/org/dive4elements/artifacts/httpclient/ConsoleClient.java	Mon Feb 28 17:49:46 2022 +0100
@@ -25,7 +25,8 @@
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
 
 import org.dive4elements.artifacts.httpclient.http.HttpClient;
 import org.dive4elements.artifacts.httpclient.http.HttpClientImpl;
@@ -59,7 +60,7 @@
     /**
      * The logger used in this class.
      */
-    private static Logger logger = Logger.getLogger(ConsoleClient.class);
+    private static Logger logger = LogManager.getLogger(ConsoleClient.class);
 
 
     public static final Configuration readConfiguration() {
--- a/src/main/java/org/dive4elements/artifacts/httpclient/http/HttpClientImpl.java	Fri Feb 25 15:15:04 2022 +0100
+++ b/src/main/java/org/dive4elements/artifacts/httpclient/http/HttpClientImpl.java	Mon Feb 28 17:49:46 2022 +0100
@@ -14,7 +14,8 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
 
 import org.restlet.Client;
 import org.restlet.Request;
@@ -46,7 +47,7 @@
  */
 public class HttpClientImpl implements HttpClient {
 
-    private static final Logger logger = Logger.getLogger(HttpClient.class);
+    private static final Logger logger = LogManager.getLogger(HttpClient.class);
 
     /** The URL part of the resource to list the existing users of the server.*/
     public static final String PATH_LIST_USERS = "/list-users";
--- a/src/main/java/org/dive4elements/artifacts/httpclient/utils/ArtifactProtocolUtils.java	Fri Feb 25 15:15:04 2022 +0100
+++ b/src/main/java/org/dive4elements/artifacts/httpclient/utils/ArtifactProtocolUtils.java	Mon Feb 28 17:49:46 2022 +0100
@@ -11,7 +11,8 @@
 
 import javax.xml.xpath.XPathConstants;
 
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -23,7 +24,7 @@
 public class ArtifactProtocolUtils {
 
     private static final Logger logger =
-        Logger.getLogger(ArtifactProtocolUtils.class);
+        LogManager.getLogger(ArtifactProtocolUtils.class);
 
 
     public static ArtifactFactory[] extractArtifactFactories(Document doc) {
--- a/src/main/java/org/dive4elements/artifacts/httpclient/utils/Configuration.java	Fri Feb 25 15:15:04 2022 +0100
+++ b/src/main/java/org/dive4elements/artifacts/httpclient/utils/Configuration.java	Mon Feb 28 17:49:46 2022 +0100
@@ -17,14 +17,15 @@
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
 
 /**
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
 public class Configuration {
 
-    private static final Logger logger = Logger.getLogger(Configuration.class);
+    private static final Logger logger = LogManager.getLogger(Configuration.class);
 
     private File config;
 
--- a/src/main/java/org/dive4elements/artifacts/httpclient/utils/XMLUtils.java	Fri Feb 25 15:15:04 2022 +0100
+++ b/src/main/java/org/dive4elements/artifacts/httpclient/utils/XMLUtils.java	Mon Feb 28 17:49:46 2022 +0100
@@ -30,7 +30,8 @@
 import javax.xml.xpath.XPathExpressionException;
 import javax.xml.xpath.XPathFactory;
 
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -49,7 +50,7 @@
     /**
      * the logger, used to log exceptions and additonaly information
      */
-    private static Logger logger = Logger.getLogger(XMLUtils.class);
+    private static Logger logger = LogManager.getLogger(XMLUtils.class);
 
     /**
      * Constructor

http://dive4elements.wald.intevation.org