From 2ecce6117e199c474a87994e969158b4ad0bebf5 Mon Sep 17 00:00:00 2001 From: Zhihong Yu Date: Fri, 30 Mar 2012 14:46:49 +0000 Subject: [PATCH] HBASE-5655 Cap space usage of default log4j rolling policy (Himanshu) git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1307453 13f79535-47bb-0310-9956-ffa450edef68 --- bin/hbase-daemon.sh | 2 +- conf/hbase-env.sh | 9 +++++++++ conf/log4j.properties | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/bin/hbase-daemon.sh b/bin/hbase-daemon.sh index ffae30a49da..f582ce70728 100755 --- a/bin/hbase-daemon.sh +++ b/bin/hbase-daemon.sh @@ -116,7 +116,7 @@ fi JAVA=$JAVA_HOME/bin/java export HBASE_LOG_PREFIX=hbase-$HBASE_IDENT_STRING-$command-$HOSTNAME export HBASE_LOGFILE=$HBASE_LOG_PREFIX.log -export HBASE_ROOT_LOGGER="INFO,DRFA" +export HBASE_ROOT_LOGGER=${HBASE_ROOT_LOGGER:-"INFO,RFA"} logout=$HBASE_LOG_DIR/$HBASE_LOG_PREFIX.out loggc=$HBASE_LOG_DIR/$HBASE_LOG_PREFIX.gc loglog="${HBASE_LOG_DIR}/${HBASE_LOGFILE}" diff --git a/conf/hbase-env.sh b/conf/hbase-env.sh index bc293b4b52f..5fa8eab41df 100644 --- a/conf/hbase-env.sh +++ b/conf/hbase-env.sh @@ -89,3 +89,12 @@ export HBASE_OPTS="-XX:+UseConcMarkSweepGC" # Tell HBase whether it should manage it's own instance of Zookeeper or not. # export HBASE_MANAGES_ZK=true + +# The default log rolling policy is RFA, where the log file is rolled as per the size defined for the +# RFA appender. Please refer to the log4j.properties file to see more details on this appender. +# In case one needs to do log rolling on a date change, one should set the environment property +# HBASE_ROOT_LOGGER to ",DRFA". +# For example: +# HBASE_ROOT_LOGGER=INFO,DRFA +# The reason for changing default to RFA is to avoid the boundary case of filling out disk space as +# DRFA doesn't put any cap on the log size. Please refer to HBase-5655 for more context. diff --git a/conf/log4j.properties b/conf/log4j.properties index 0010d6a129c..d829fcdf05b 100644 --- a/conf/log4j.properties +++ b/conf/log4j.properties @@ -25,6 +25,21 @@ log4j.appender.DRFA.layout=org.apache.log4j.PatternLayout # Pattern format: Date LogLevel LoggerName LogMessage log4j.appender.DRFA.layout.ConversionPattern=%d{ISO8601} %p %c: %m%n +# Rolling File Appender properties +hbase.log.maxfilesize=256MB +hbase.log.maxbackupindex=20 + +# Rolling File Appender +log4j.appender.RFA=org.apache.log4j.RollingFileAppender +log4j.appender.RFA.File=${hbase.log.dir}/${hbase.log.file} + +log4j.appender.RFA.MaxFileSize=${hbase.log.maxfilesize} +log4j.appender.RFA.MaxBackupIndex=${hbase.log.maxbackupindex} + +log4j.appender.RFA.layout=org.apache.log4j.PatternLayout +log4j.appender.RFA.layout.ConversionPattern=%d{ISO8601} %p %c: %m%n + + # Debugging Pattern format #log4j.appender.DRFA.layout.ConversionPattern=%d{ISO8601} %-5p %c{2} (%F:%M(%L)) - %m%n