2
votes

I built a zookeeper cluster and it runs very well. But I found that the log directory I set in the zoo.cfg seems not working. Below is my config about log directory and snapshots directory.

dataDir=/var/lib/zookeeper
dataLogDir=/var/lib/zookeeper/logs

However, file zookeeper.out is generated in /var/lib/zookeeper rather than the subsidiary log folder /var/lib/zookeeper/logs.

I restarted zookeeper on every server many times, but made no sense.

1
dataDir and dataLogDir are not in the same line, the are in 2 separated lines.GssFlyaway
GssFlyaway, that's only stackoverflow bad formatting; put 2 spaces at line end in order to have line breakadrhc
stackoverflow.com/questions/26612908/… bin/zkServer.sh and conf/log4j.properties explained there: ZOO_LOG_DIR - to set the path for both zookeeper.out and log4j. ZOO_LOG4J_PROP - to set the log4j logging level and what log appenders are turned onuser7568519

1 Answers

2
votes

This happens because zookeeper.out is related to other type of log (application log) instead of the one specified by dataLogDir which relates to transaction log.

dataLogDir
This option will direct the machine to write the transaction log to the dataLogDir rather than the dataDir. This allows a dedicated log device to be used, and helps avoid competition between logging and snaphots.

By checking zkServer.sh you'll see that zookeeper.out is related to _ZOO_DAEMON_OUT which depends on ZOO_LOG_DIR which is set by default by zkEnv.sh. Depending on your environment and zookeeper (ZK) version the zookeeper.out file might land in different places (according to this answer even in the working directory from which ZK is started). For application logging you'll better configure the log4j.properties file; that's because ZK uses log4j.