diff backend/contrib/import_river.sh @ 9726:0a5239a1e46e 3.2.x

Upgrade to Log4j 2
author Tom Gottfried <tom@intevation.de>
date Wed, 02 Mar 2022 10:26:50 +0100
parents f7c49975cc15
children
line wrap: on
line diff
--- a/backend/contrib/import_river.sh	Fri Feb 25 17:17:56 2022 +0100
+++ b/backend/contrib/import_river.sh	Wed Mar 02 10:26:50 2022 +0100
@@ -151,14 +151,25 @@
 LOG_DIR=${LOG}/`basename $GEW_FILE .gew`-$DATE
 mkdir -p ${LOG_DIR}
 
-cat > "$LOG_DIR/log4j.properties" << "EOF"
-log4j.rootLogger=INFO, IMPORTER
-log4j.appender.IMPORTER.layout=org.apache.log4j.PatternLayout
-log4j.appender.IMPORTER.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
-log4j.appender.IMPORTER=org.apache.log4j.RollingFileAppender
-log4j.appender.IMPORTER.File=./import.log
-log4j.appender.IMPORTER.MaxFileSize=100000KB
-log4j.appender.IMPORTER.MaxBackupIndex=10
+cat > "$LOG_DIR/log4j2.xml" << "EOF"
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration>
+    <Appenders>
+        <RollingFile
+            name="RollingFile"
+            fileName="import.log"
+            filePattern="import.log.%i">
+            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5p %c - %m%n"/>
+            <SizeBasedTriggeringPolicy size="100000 KB"/>
+            <DefaultRolloverStrategy max="10"/>
+        </RollingFile>
+    </Appenders>
+    <Loggers>
+        <Root level="DEBUG">
+            <AppenderRef ref="RollingFile"/>
+        </Root>
+    </Loggers>
+</Configuration>
 EOF
 
 if [ "$POSTGRES" = "TRUE" ]; then
@@ -186,12 +197,11 @@
     LOG_FILE=${LOG_DIR}/hydro.log
     echo Importing Hydrological data.
     echo Logging into: $LOG_FILE
-    sed -i 's!\(log4j.appender.IMPORTER.File=\).*!\1'"$LOG_FILE"'!' \
-        $LOG_DIR/log4j.properties
+    sed -i "s/import.log/$LOG_FILE/" $LOG_DIR/log4j2.xml
     java -jar \
     -Xmx$MIN_MEMORY \
     -server \
-    -Dlog4j.configuration=file://$LOG_DIR/log4j.properties \
+    -Dlog4j2.configurationFile=file://$LOG_DIR/log4j2.xml \
     -Dflys.backend.user=$DBUSER \
     -Dflys.backend.password=$DBPASS \
     -Dflys.backend.url=$BACKEND_URL \
@@ -235,12 +245,11 @@
     LOG_FILE=${LOG_DIR}/morpho.log
     echo Importing Morphological data.
     echo Logging into: $LOG_FILE
-    sed -i 's!\(log4j.appender.IMPORTER.File=\).*!\1'"$LOG_FILE"'!' \
-        $LOG_DIR/log4j.properties
+    sed -i "s/import.log/$LOG_FILE/" $LOG_DIR/log4j2.xml
     java -jar \
     -Xmx$MIN_MEMORY \
     -server \
-    -Dlog4j.configuration=file://$LOG_DIR/log4j.properties \
+    -Dlog4j2.configurationFile=file://$LOG_DIR/log4j2.xml \
     -Dflys.backend.user=$DBUSER \
     -Dflys.backend.password=$DBPASS \
     -Dflys.backend.url=$BACKEND_URL \
@@ -284,12 +293,11 @@
     LOG_FILE=${LOG_DIR}/prf.log
     echo Importing cross section data.
     echo Logging into: $LOG_FILE
-    sed -i 's!\(log4j.appender.IMPORTER.File=\).*!\1'"$LOG_FILE"'!' \
-        $LOG_DIR/log4j.properties
+    sed -i "s/import.log/$LOG_FILE/" $LOG_DIR/log4j2.xml
     java -jar \
     -Xmx$MIN_MEMORY \
     -server \
-    -Dlog4j.configuration=file://$LOG_DIR/log4j.properties \
+    -Dlog4j2.configurationFile=file://$LOG_DIR/log4j2.xml \
     -Dflys.backend.user=$DBUSER \
     -Dflys.backend.password=$DBPASS \
     -Dflys.backend.url=$BACKEND_URL \

http://dive4elements.wald.intevation.org