From daf42fce61a9f66a616d55f6de280374d74a5b83 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Thu, 4 Jun 2020 14:51:25 -0400 Subject: [PATCH] Explicitly specify log4j config file. (#1480) --- import-marc.bat | 17 ++++++++++++++--- import-marc.sh | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/import-marc.bat b/import-marc.bat index 2a2bcc96381..dca28dbb708 100644 --- a/import-marc.bat +++ b/import-marc.bat @@ -10,7 +10,7 @@ rem Path to the java rem INDEX_OPTIONS rem Options to pass to the JVM -rem Make sure that environment edits are local and that we have access to the +rem Make sure that environment edits are local and that we have access to the rem Windows command extensions. setlocal enableextensions if not errorlevel 1 goto extensionsokay @@ -61,7 +61,7 @@ rem ################################################## rem # Set VUFIND_HOME rem ################################################## if not "!%VUFIND_HOME%!"=="!!" goto vufindhomefound -rem VUFIND_HOME not set -- try to call env.bat to +rem VUFIND_HOME not set -- try to call env.bat to rem fix the problem before we give up completely if exist env.bat goto useenvbat rem If env.bat doesn't exist, the user hasn't run the installer yet. @@ -100,6 +100,17 @@ echo WARNING: VUFIND_LOCAL_DIR environment variable is not set. Is this intentio set PROPERTIES_FILE=%VUFIND_HOME%\import\import.properties :propertiesfound +rem ################################################## +rem # Set log4j config file if not already provided +rem ################################################## +if defined LOG4J_CONFIG goto log4jfound +if not exist %VUFIND_LOCAL_DIR%\import\log4j.properties goto nolocallog4j +set LOG4J_CONFIG=%VUFIND_LOCAL_DIR%\import\log4j.properties +goto log4jfound +:nolocallog4j +set LOG4J_CONFIG=%VUFIND_HOME%\import\log4j.properties +:log4jfound + rem ################################################## rem # Set Command Options rem ################################################## @@ -108,7 +119,7 @@ for %%a in (%VUFIND_HOME%\import\solrmarc_core_*.jar) do set JAR_FILE=%%a rem ##################################################### rem # Execute Importer rem ##################################################### -set RUN_CMD=%JAVA% %INDEX_OPTIONS% -Duser.timezone=UTC %EXTRA_SOLRMARC_SETTINGS% -jar %JAR_FILE% %PROPERTIES_FILE% -solrj %VUFIND_HOME%\solr\vendor\dist\solrj-lib %1 +set RUN_CMD=%JAVA% %INDEX_OPTIONS% -Duser.timezone=UTC -Dlog4j.configuration="file:///%LOG4J_CONFIG%" %EXTRA_SOLRMARC_SETTINGS% -jar %JAR_FILE% %PROPERTIES_FILE% -solrj %VUFIND_HOME%\solr\vendor\dist\solrj-lib %1 echo Now Importing %1 ... echo %RUN_CMD% %RUN_CMD% diff --git a/import-marc.sh b/import-marc.sh index 4965ca45b33..309cc11501e 100755 --- a/import-marc.sh +++ b/import-marc.sh @@ -102,6 +102,19 @@ then fi fi +################################################## +# Set log4j config file if not already provided +################################################## +if [ -z "$LOG4J_CONFIG" ] +then + if [ -f "$VUFIND_LOCAL_DIR/import/log4j.properties" ] + then + LOG4J_CONFIG="$VUFIND_LOCAL_DIR/import/log4j.properties" + else + LOG4J_CONFIG="$VUFIND_HOME/import/log4j.properties" + fi +fi + ################################################## # Set Command Options ################################################## @@ -127,7 +140,7 @@ MARC_FILE=`basename $1` # Execute Importer ##################################################### -RUN_CMD="$JAVA $INDEX_OPTIONS -Duser.timezone=UTC $EXTRA_SOLRMARC_SETTINGS -jar $JAR_FILE $PROPERTIES_FILE -solrj $VUFIND_HOME/solr/vendor/dist/solrj-lib $MARC_PATH/$MARC_FILE" +RUN_CMD="$JAVA $INDEX_OPTIONS -Duser.timezone=UTC -Dlog4j.configuration=file://$LOG4J_CONFIG $EXTRA_SOLRMARC_SETTINGS -jar $JAR_FILE $PROPERTIES_FILE -solrj $VUFIND_HOME/solr/vendor/dist/solrj-lib $MARC_PATH/$MARC_FILE" echo "Now Importing $1 ..." # solrmarc writes log messages to stderr, write RUN_CMD to the same place echo "`date '+%h %d, %H:%M:%S'` $RUN_CMD" >&2 -- GitLab