[
https://issues.apache.org/jira/browse/ZOOKEEPER-2170?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14513174#comment-14513174
]
Chris Nauroth commented on ZOOKEEPER-2170:
------------------------------------------
Hello [~arshad.mohammad].
As you noted, a system property will override the default value in the
log4j.properties file. If you're launching ZooKeeper through its scripts
(zkServer.sh/zkCli.sh), then libExec/zkEnv.sh will set the {{ZOO_LOG4J_PROP}}
to {{INFO}} level:
{code}
ZOO_LOG4J_PROP="INFO,CONSOLE"
{code}
Because of that, editing the value in log4j.properties directly won't change
the logging level. Instead, we can control it by changing the
{{ZOO_LOG4J_PROP}} environment variable, either by setting it in your
environment before launching the script or by editing libexec/zkEnv.sh.
Another thing to note is that in addition to the loggers, there are separate
properties controlling thresholds on the appenders too. I see from the
description that you want {{DEBUG}} level, but the default thresholds are
{{INFO}}:
{code}
zookeeper.console.threshold=INFO
zookeeper.log.threshold=INFO
log4j.appender.CONSOLE.Threshold=${zookeeper.console.threshold}
log4j.appender.ROLLINGFILE.Threshold=${zookeeper.log.threshold}
{code}
These settings don't map directly to their own environment variables like
{{ZOO_LOG4J_PROP}}. Instead, you can use {{SERVER_JVMFLAGS}} and
{{CLIENT_JVMFLAGS}} to override them.
Putting all of that together, you can get {{DEBUG}} logging on both the server
and client side by making the following changes in libexec/zkEnv.sh:
{code}
if [ "x${ZOO_LOG4J_PROP}" = "x" ]
then
ZOO_LOG4J_PROP="DEBUG,CONSOLE"
fi
{code}
{code}
# default heap for zookeeper server
ZK_SERVER_HEAP="${ZK_SERVER_HEAP:-1000}"
export SERVER_JVMFLAGS="-Xmx${ZK_SERVER_HEAP}m
-Dzookeeper.console.threshold=DEBUG $SERVER_JVMFLAGS"
# default heap for zookeeper client
ZK_CLIENT_HEAP="${ZK_CLIENT_HEAP:-256}"
export CLIENT_JVMFLAGS="-Xmx${ZK_CLIENT_HEAP}m
-Dzookeeper.console.threshold=DEBUG $CLIENT_JVMFLAGS"
{code}
Alternatively, you can set these environment variables before launching the
scripts, or you could write a completely different log4j.properties file if you
prefer a different setup that doesn't rely on these environment variables.
I just tested this on a fresh trunk distro build, and it worked. ZOOKEEPER-980
originally introduced these settings, inspired by similar scripts in Hadoop.
It appears this is all working by design, so I'm going to resolve the issue as
Not a Problem. If you still think there is a bug, please feel free to reopen
it and add more details in the comments.
Thanks!
> Zookeeper is not logging as per the configuraiton in log4j.properties
> ----------------------------------------------------------------------
>
> Key: ZOOKEEPER-2170
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2170
> Project: ZooKeeper
> Issue Type: Bug
> Reporter: Arshad Mohammad
> Fix For: 3.6.0
>
>
> In conf/log4j.properties default root logger is
> {code}
> zookeeper.root.logger=INFO, CONSOLE
> {code}
> Changing root logger to bellow value or any other value does not change
> logging effect
> {code}
> zookeeper.root.logger=DEBUG, ROLLINGFILE
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)