[PATCH] Importer: fix logging in import_river.sh

Wald Commits scm-commit at wald.intevation.org
Thu Jan 16 12:03:17 CET 2014


# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1389870174 -3600
# Node ID c842ebb0db866bc467640de65fe5c41cee75a29d
# Parent  3d772f52080a62fb011da1e70df3177f63fdff24
Importer: fix logging in import_river.sh.

diff -r 3d772f52080a -r c842ebb0db86 backend/contrib/import_river.sh
--- a/backend/contrib/import_river.sh	Mon Jan 13 11:52:22 2014 +0100
+++ b/backend/contrib/import_river.sh	Thu Jan 16 12:02:54 2014 +0100
@@ -70,7 +70,7 @@
    -p, --port=<number>             Use port number <number>. Default: $DEFAULT_PORT
    -d, --db-name=<database_name>   Name of the database / backend. Default: $DEFAULT_BACKEND_NAME
    -l, --log-dir=<directory>       Directory in which to create the log files.
-                                   Default: $LOG_DIR
+                                   Default: $PWD/logs
    --postgres                      Database is PostgreSQL
    --skip-hydro                    Skip import of hydrological data
    --skip-morpho                   Skip import of morphological data
@@ -80,8 +80,8 @@
 exit 0
 }
 
-OPTS=`getopt -o ?u:w:h:p:d: \
-     -l help,username:,password:,host:,port:,db-name:,skip-hydro,skip-morpho,skip-geo,skip-prf,postgres \
+OPTS=`getopt -o ?u:w:h:p:d:l: \
+     -l help,username:,password:,host:,port:,db-name:,log-dir:,skip-hydro,skip-morpho,skip-geo,skip-prf,postgres \
      -n $0 -- "$@"`
 if [ $? != 0 ] ; then usage; fi
 eval set -- "$OPTS"
@@ -146,7 +146,7 @@
 if [ -z $BACKEND_NAME ]; then
   BACKEND_NAME=$DEFAULT_BACKEND_NAME
 fi
-if [ -z $LOGDIR ]; then
+if [ -z $LOG ]; then
   LOG=$DEFAULT_LOG
 fi
 
@@ -164,6 +164,16 @@
 LOG_DIR=${LOG}/`basename $GEW_FILE .gew`-$DATE
 mkdir -p ${LOG_DIR}
 
+cat > "$LOG_DIR/log4j.properties" << "EOF"
+log4j.rootLogger=DEBUG, 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
+EOF
+
 if [ "$POSTGRES" = "TRUE" ]; then
     JAR=$(echo "$JAR" | sed 's/importer/importer_psql/')
     if [ ! -r "$JAR" ]; then
@@ -189,7 +199,8 @@
     LOG_FILE=${LOG_DIR}/hydro.log
     echo Importing Hydrological data.
     echo Logging into: $LOG_FILE
-    sed 's!./import.log!'"$LOG_FILE"'!' conf/log4j.properties > $LOG_DIR/log4j.properties
+    sed -i 's!\(log4j.appender.IMPORTER.File=\).*!\1'"$LOG_FILE"'!' \
+        $LOG_DIR/log4j.properties
     java -jar \
     -Xmx$MIN_MEMORY \
     -server \
@@ -236,7 +247,8 @@
     LOG_FILE=${LOG_DIR}/morpho.log
     echo Importing Morphological data.
     echo Logging into: $LOG_FILE
-    sed 's!./import.log!'"$LOG_FILE"'!' conf/log4j.properties > $LOG_DIR/log4j.properties
+    sed -i 's!\(log4j.appender.IMPORTER.File=\).*!\1'"$LOG_FILE"'!' \
+        $LOG_DIR/log4j.properties
     java -jar \
     -Xmx$MIN_MEMORY \
     -server \
@@ -283,7 +295,8 @@
     LOG_FILE=${LOG_DIR}/prf.log
     echo Importing cross section data.
     echo Logging into: $LOG_FILE
-    sed 's!./import.log!'"$LOG_FILE"'!' conf/log4j.properties > $LOG_DIR/log4j.properties
+    sed -i 's!\(log4j.appender.IMPORTER.File=\).*!\1'"$LOG_FILE"'!' \
+        $LOG_DIR/log4j.properties
     java -jar \
     -Xmx$MIN_MEMORY \
     -server \
diff -r 3d772f52080a -r c842ebb0db86 backend/doc/documentation/de/importer-hydr-morph.tex
--- a/backend/doc/documentation/de/importer-hydr-morph.tex	Mon Jan 13 11:52:22 2014 +0100
+++ b/backend/doc/documentation/de/importer-hydr-morph.tex	Thu Jan 16 12:02:54 2014 +0100
@@ -908,3 +908,6 @@
 \end{lstlisting}
 Alternativ können auch in diesem Skript einige Variablen 
 (\textit{DEFAULT\_*}) angepasst werden.
+Das Logging kann in diesem Fall nicht wie oben beschrieben
+über \textit{conf/log4j.properties} angepasst werden, da hier
+mehrere Log-Dateien geschrieben werden müssen.


More information about the Dive4elements-commits mailing list