[PATCH] Upgrade to Log4j 2
Wald Commits
scm-commit at wald.intevation.org
Mon Feb 28 17:50:14 CET 2022
# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1646066986 -3600
# Mon Feb 28 17:49:46 2022 +0100
# Branch 3.2.x
# Node ID e602a29f1dcc5d824bdd476a001ed8a063031c35
# Parent 7261c948425cb4fb6210f1103eacc94a41e4f157
Upgrade to Log4j 2
diff -r 7261c948425c -r e602a29f1dcc bin/run.sh
--- 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
diff -r 7261c948425c -r e602a29f1dcc conf/log4j.properties
--- 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
diff -r 7261c948425c -r e602a29f1dcc pom.xml
--- 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>
diff -r 7261c948425c -r e602a29f1dcc src/main/java/org/dive4elements/artifacts/httpclient/ConsoleClient.java
--- 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() {
diff -r 7261c948425c -r e602a29f1dcc src/main/java/org/dive4elements/artifacts/httpclient/http/HttpClientImpl.java
--- 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";
diff -r 7261c948425c -r e602a29f1dcc src/main/java/org/dive4elements/artifacts/httpclient/utils/ArtifactProtocolUtils.java
--- 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) {
diff -r 7261c948425c -r e602a29f1dcc src/main/java/org/dive4elements/artifacts/httpclient/utils/Configuration.java
--- 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 at 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;
diff -r 7261c948425c -r e602a29f1dcc src/main/java/org/dive4elements/artifacts/httpclient/utils/XMLUtils.java
--- 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
More information about the Dive4Elements-commits
mailing list