changeset 7728:c842ebb0db86

Importer: fix logging in import_river.sh.
author Tom Gottfried <tom@intevation.de>
date Thu, 16 Jan 2014 12:02:54 +0100
parents 3d772f52080a
children e1c30527c104
files backend/contrib/import_river.sh backend/doc/documentation/de/importer-hydr-morph.tex
diffstat 2 files changed, 23 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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 \
--- 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.

http://dive4elements.wald.intevation.org