1. 程式人生 > >修改Zookeeper日誌輸出路徑,並按照日期輸出

修改Zookeeper日誌輸出路徑,並按照日期輸出

1、修改log4j.properties

vi  /opt/zookeeper-3.4.8/conf/log4j.properties

# Define some default values that can be overridden by system properties
zookeeper.root.logger=INFO,ROLLINGFILE 
zookeeper.console.threshold=INFO
zookeeper.log.dir=.
zookeeper.log.file=zookeeper.log
zookeeper.log.threshold=DEBUG
zookeeper.tracelog.dir=.
zookeeper.tracelog.file=zookeeper_trace.log


#
# Add ROLLINGFILE to rootLogger to get log file output
#    Log DEBUG level and above messages to a log file
# 按照日期每天輸出logs


log4j.appender.ROLLINGFILE=org.apache.log4j.DailyRollingFileAppender
log4j.appender.ROLLINGFILE.Threshold=${zookeeper.log.threshold}
log4j.appender.ROLLINGFILE.File=${zookeeper.log.dir}/${zookeeper.log.file}


# Max log file size of 10MB
#log4j.appender.ROLLINGFILE.MaxFileSize=10MB
# uncomment the next line to limit number of backup files
#log4j.appender.ROLLINGFILE.MaxBackupIndex=10


2、修改zkEnv.sh

vi  /opt/zookeeper-3.4.8/bin/zkEnv.sh

I…

if [ -f "$ZOOCFGDIR/Java.env" ]
then
    . "$ZOOCFGDIR/java.env"
fi


if [ "x${ZOO_LOG_DIR}" = "x" ]
then
#日誌輸出路徑 不需mkdir zookeeper啟動時自動建立
    ZOO_LOG_DIR="/opt/zookeeper-3.4.8/logs"
fi


if [ "x${ZOO_LOG4J_PROP}" = "x" ]
then
    ZOO_LOG4J_PROP="INFO,ROLLINGFILE"


fi


if [ "$JAVA_HOME" != "" ]; then
  JAVA="$JAVA_HOME/bin/java"
else
  JAVA=java
fi



輸出的格式為:zookeeper.log

前一天日誌的輸出格式為:zookeeper.log.2016-09-01