In my zookeeper/conf/log4j.properties file I set the zookeeper.log.dir to $HOME/zklogs
When I use zkServer.sh it does not use that directory. Instead it uses the ${Z
As far as I can see from zkEnv.sh zookeeper/conf folder is already in the classpath. There are two problems there:
even if you do specify ZOO_LOG_DIR, ZK may still be unable to find your log4j.properties file, because zkEnv.sh specifies CLASSPATH like this:
$CLASSPATH="$ZOOCFGDIR:$CLASSPATH"
this works fine if your $CLASSPATH environment variable is not empty, however when it is empty, it just leaves a trailing colon, which screws up your classpath. I changed the lines above to this:
#add the zoocfg dir to classpath
if [ "x${CLASSPATH}" = "x" ]
then
CLASSPATH="$ZOOCFGDIR"
else
CLASSPATH="$ZOOCFGDIR:$CLASSPATH"
fi
and also passed ZOO_LOG_DIR environment for ZK, because zkServer.sh generates -Dzookeeper.log.dir VM argument when starting up ZK. Here is the command that starts ZooKeeper for me, makes it read /opt/zookeeper/conf/log4j.properties and keep log files in /opt/zimbra/log:
ZOO_LOG_DIR=/opt/zimbra/log /opt/zookeeper/bin/zkServer.sh start