zookeeper.log file not created inside logs directory
Asked Answered
C

1

7

I'm unable to create zookeeper.log under the directory i had specified in the log4j.properties. I'm not sure what's going wrong, Can someone please direct me what should I be looking into to solve this issue?

Please find below the log4j.properties file.

zookeeper.root.logger=  INFO, ROLLINGFILE
zookeeper.console.threshold=  INFO

zookeeper.log.dir= /usr/local/zookeeper-3.4.5-cdh5.3.1/logs
zookeeper.log.file= zookeeper.log
zookeeper.log.threshold= INFO
zookeeper.log.maxfilesize=  256MB
zookeeper.log.maxbackupindex=  20

zookeeper.tracelog.dir= /usr/local/zookeeper-3.4.5-cdh5.3.1/logs
zookeeper.tracelog.file= zookeeper_trace.log

log4j.rootLogger= ${zookeeper.root.logger}

#
# console
# Add "console" to rootlogger above if you want to use this
#
log4j.appender.CONSOLE=  org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Threshold=  ${zookeeper.console.threshold}
log4j.appender.CONSOLE.layout=  org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=  %d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n

#
# Add ROLLINGFILE to rootLogger to get log file output
#
log4j.appender.ROLLINGFILE= org.apache.log4j.RollingFileAppender
log4j.appender.ROLLINGFILE.Threshold= ${zookeeper.log.threshold}
log4j.appender.ROLLINGFILE.File= ${zookeeper.log.dir}/${zookeeper.log.file}
log4j.appender.ROLLINGFILE.MaxFileSize= ${zookeeper.log.maxfilesize}
log4j.appender.ROLLINGFILE.MaxBackupIndex=${zookeeper.log.maxbackupindex}
log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n

#
# Add TRACEFILE to rootLogger to get log file output
#    Log TRACE level and above messages to a log file
#
log4j.appender.TRACEFILE=org.apache.log4j.FileAppender
log4j.appender.TRACEFILE.Threshold=TRACE
log4j.appender.TRACEFILE.File=${zookeeper.log.dir}/${zookeeper.tracelog.file}

log4j.appender.TRACEFILE.layout= org.apache.log4j.PatternLayout
### Notice we are including log4j's NDC here (%x)
log4j.appender.TRACEFILE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L][%x] - %m%n
Catechol answered 24/2, 2015 at 8:44 Comment(3)
Why tagging chef and chef-recipe as it's a log4j problem ? (I would bet on a permission problem on the zookeeper directory for the user zookeeper run as)Masseuse
Ok I will remove it. This was problem with assigning ZOOCFGDIR to class path in zookeeper-env.sh. Its working fine nowCatechol
You may answer yourself with the description on how you solved it, it may help someone in the future ;)Masseuse
C
3

For Chef : 1) Create zookeeper-env.sh.erb template file and set the classpath.

NAME=zookeeper
ZOODIR="path/to/zookeeper/directory"
ZOOCFGDIR="$ZOODIR/conf"

CLASSPATH="$ZOOCFGDIR:$ZOODIR/build/classes:$ZOODIR/bin/build/lib/*.jar:$ZOODIR/lib/slf4j-api-1.7.5.jar:$ZOODIR/lib/netty-3.2.2.Final.jar:$ZOODIR/lib/log4j-1.2.16.jar:$ZOODIR/lib/jline-0.9.94.jar:$ZOODIR/zookeeper-3.4.5-cdh5.3.1.jar:$ZOODIR/src/java/lib/*.jar"


ZOOCFG="$ZOOCFGDIR/zoo.cfg"
ZOO_LOG_DIR="path/to/zookeeper/log/directory"
PIDDIR="~/zookeeper/data/$NAME"
PIDFILE="$PIDDIR/$NAME.pid"
SCRIPTNAME="/etc/init.d/$NAME"
JAVA="/usr/java/jdk1.8.0_25"
ZOOMAIN="org.apache.zookeeper.server.quorum.QuorumPeerMain"
ZOO_LOG4J_PROP="INFO,ROLLINGFILE"
JMXLOCALONLY=false
JAVA_OPTS="-Xms128M -Xmx512M"
  1. Place this file under zookeeper/conf directory

I assume this works because zoocfg dir is being accessed through zookeeper-env.sh as seen in zkEnv.sh file under zookeeper/bin folder:

if [ -f "${ZOOCFGDIR}/zookeeper-env.sh" ]; then
  . "${ZOOCFGDIR}/zookeeper-env.sh"
fi
Catechol answered 25/2, 2015 at 11:7 Comment(1)
I know this is a crazy old update... but Xmx is separately set by the zkEnv.sh from a value of ZK_SERVER_HEAP. Best to set it there vs in a JAVA_OPTS.Meany

© 2022 - 2024 — McMap. All rights reserved.