Saturday, September 29, 2012

customized log4j.property location by adding system property

I put log4j.properties in classpath, but it is not located classpath root directory. I put all properties into properties directory to keep root classpath organized clean structure. Since I moved the log4j.properties file, log4j makes error when process start up. I had to put below line which add system property.
-Dlog4j.configuration="properties/log4j.properties" then it works well now.

LIB_HOME=/home01/batch/batch/common_lib
JAVA_HOME=/home02/bea10/jdk160_24

CLASSPATH=${LIB_HOME}/activation-1.1.jar
CLASSPATH=${CLASSPATH}:${LIB_HOME}/api.services-50.jar
CLASSPATH=${CLASSPATH}:${LIB_HOME}/axis-1.4.jar
CLASSPATH=${CLASSPATH}:${LIB_HOME}/axis-jaxrpc-1.4.jar
CLASSPATH=${CLASSPATH}:${LIB_HOME}/axis-saaj-1.4.jar
CLASSPATH=${CLASSPATH}:${LIB_HOME}/axis-wsdl4j-1.5.1.jar
CLASSPATH=${CLASSPATH}:${LIB_HOME}/commons-beanutils-1.8.3.jar
CLASSPATH=${CLASSPATH}:${LIB_HOME}/commons-digester-1.8.jar
CLASSPATH=${CLASSPATH}:${LIB_HOME}/commons-discovery-0.2.jar
CLASSPATH=${CLASSPATH}:${LIB_HOME}/commons-lang-2.6.jar
CLASSPATH=${CLASSPATH}:${LIB_HOME}/commons-logging-1.0.4.jar
CLASSPATH=${CLASSPATH}:${LIB_HOME}/commons-net-3.1.jar
CLASSPATH=${CLASSPATH}:${LIB_HOME}/commons-validator-1.4.0.jar
CLASSPATH=${CLASSPATH}:${LIB_HOME}/ibatis-sqlmap-2.3.4.726.jar
CLASSPATH=${CLASSPATH}:${LIB_HOME}/log4j-1.2.16.jar
CLASSPATH=${CLASSPATH}:${LIB_HOME}/mail-1.4.5.jar
CLASSPATH=${CLASSPATH}:${LIB_HOME}/server.service-1.0.jar
CLASSPATH=${CLASSPATH}:${LIB_HOME}/servlet-api-2.5.jar
CLASSPATH=${CLASSPATH}:${LIB_HOME}/ojdbc6.jar
CLASSPATH=${CLASSPATH}:${LIB_HOME}/uk_batch.jar

export CLASSPATH 
sdate=`date +'%Y%m%d'`
stime=`date +'%H%M%S'`

${JAVA_HOME}/bin/java -Dlog4j.configuration="properties/log4j.properties" -cp ${CLASSPATH} batch.Run


No comments:

Post a Comment