You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@zookeeper.apache.org by Ben Hsu <be...@criticalmedia.com> on 2015/02/23 18:01:46 UTC

turning off per class logging

Hello

I wish to suppress zookeeper logging at the class level. I see a lot of
messages in my log along these lines:

2015-02-23 16:54:53,192 - INFO  [NIOServerCxn.Factory:/0.0.0.0:2181
:NIOServerCnxnFactory@197] - Accepted socket connection from /
127.0.0.1:37142
2015-02-23 16:54:53,202 - INFO  [NIOServerCxn.Factory:/0.0.0.0:2181
:NIOServerCnxn@827] - Processing srvr command from /127.0.0.1:37142
2015-02-23 16:54:53,205 - INFO  [Thread-3:NIOServerCnxn@1007] - Closed
socket connection for client /127.0.0.1:37142 (no session established for
client)
2015-02-23 16:54:53,234 - INFO  [NIOServerCxn.Factory:/0.0.0.0:2181
:NIOServerCnxnFactory@197] - Accepted socket connection from /
127.0.0.1:37143
2015-02-23 16:54:53,235 - INFO  [NIOServerCxn.Factory:/0.0.0.0:2181
:NIOServerCnxn@827] - Processing wchs command from /127.0.0.1:37143
2015-02-23 16:54:53,237 - INFO  [Thread-4:NIOServerCnxn@1007] - Closed
socket connection for client /127.0.0.1:37143 (no session established for
client)


I want to set logging for the NIOServerCnxn and NIOServerCnxnFactory
classes to WARN, but keep everything else at the INFO level. How can I do
this?

I tried to set log4j properties at the class level:

java -Dlog4j.logger.org.apache.zookeeper.server.NIOServerxnFactory=WARN
-Dlog4j.logger.org.apache.zookeeper.server.NIOServerCnxn=WARN
-Dzookeeper.log.dir=/var/log/ -Dzookeeper.root.logger=CONSOLE -cp
/etc/zookeeper::/usr/lib64/zookeeper/bin/../zookeeper-3.4.6.jar:/usr/lib64/zookeeper/bin/../lib/jline-0.9.94.jar:/usr/lib64/zookeeper/bin/../lib/log4j-1.2.16.jar:/usr/lib64/zookeeper/bin/../lib/netty-3.7.0.Final.jar:/usr/lib64/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/usr/lib64/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.local.only=false
org.apache.zookeeper.server.quorum.QuorumPeerMain /etc/zookeeper/zoo.cfg

This didn't work: log messages for those two classes are still coming out.
I tried with the lower case ("warn" instead of "WARN") and that didn't work
either

Further playing around with setting zookeeper.root.logger to ERROR makes me
wonder if zookeeper is honoring these command line parameters at all

I don't see any reference to a log4j.properties, and running it under
strace tells me its not opening a log4j file anywhere.

any ideas?

Re: turning off per class logging

Posted by Ben Hsu <be...@criticalmedia.com>.
Thank you, that was what was wrong.

I thought log4j could be set at the command line because I saw these lines
in zkServer.sh:

"-Dzookeeper.log.dir=${ZOO_LOG_DIR}"
"-Dzookeeper.root.logger=${ZOO_LOG4J_PROP}"

Are these not related to log4j?

Thank you for your help

On Mon, Feb 23, 2015 at 4:04 PM, Luke Stephenson <lu...@gmail.com>
wrote:

> Hello,
>
> This is some general feedback, nothing specific to zookeeper.
>
> Where in the log4j documentation does it say you can set the log level per
> class as a jvm property?  I've not seen this before and couldn't see it
> when I looked through the documentation.
>
> http://logging.apache.org/log4j/2.x/manual/configuration.html#SystemProperties
> .
>
> I'd suggest using a log4j xml configuration file as documented here
> http://logging.apache.org/log4j/2.x/manual/configuration.html
>
> Luke
>
> On 24 February 2015 at 04:01, Ben Hsu <be...@criticalmedia.com> wrote:
>
> > Hello
> >
> > I wish to suppress zookeeper logging at the class level. I see a lot of
> > messages in my log along these lines:
> >
> > 2015-02-23 16:54:53,192 - INFO  [NIOServerCxn.Factory:/0.0.0.0:2181
> > :NIOServerCnxnFactory@197] - Accepted socket connection from /
> > 127.0.0.1:37142
> > 2015-02-23 16:54:53,202 - INFO  [NIOServerCxn.Factory:/0.0.0.0:2181
> > :NIOServerCnxn@827] - Processing srvr command from /127.0.0.1:37142
> > 2015-02-23 16:54:53,205 - INFO  [Thread-3:NIOServerCnxn@1007] - Closed
> > socket connection for client /127.0.0.1:37142 (no session established
> for
> > client)
> > 2015-02-23 16:54:53,234 - INFO  [NIOServerCxn.Factory:/0.0.0.0:2181
> > :NIOServerCnxnFactory@197] - Accepted socket connection from /
> > 127.0.0.1:37143
> > 2015-02-23 16:54:53,235 - INFO  [NIOServerCxn.Factory:/0.0.0.0:2181
> > :NIOServerCnxn@827] - Processing wchs command from /127.0.0.1:37143
> > 2015-02-23 16:54:53,237 - INFO  [Thread-4:NIOServerCnxn@1007] - Closed
> > socket connection for client /127.0.0.1:37143 (no session established
> for
> > client)
> >
> >
> > I want to set logging for the NIOServerCnxn and NIOServerCnxnFactory
> > classes to WARN, but keep everything else at the INFO level. How can I do
> > this?
> >
> > I tried to set log4j properties at the class level:
> >
> > java -Dlog4j.logger.org.apache.zookeeper.server.NIOServerxnFactory=WARN
> > -Dlog4j.logger.org.apache.zookeeper.server.NIOServerCnxn=WARN
> > -Dzookeeper.log.dir=/var/log/ -Dzookeeper.root.logger=CONSOLE -cp
> >
> >
> /etc/zookeeper::/usr/lib64/zookeeper/bin/../zookeeper-3.4.6.jar:/usr/lib64/zookeeper/bin/../lib/jline-0.9.94.jar:/usr/lib64/zookeeper/bin/../lib/log4j-1.2.16.jar:/usr/lib64/zookeeper/bin/../lib/netty-3.7.0.Final.jar:/usr/lib64/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/usr/lib64/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar
> > -Dcom.sun.management.jmxremote
> > -Dcom.sun.management.jmxremote.local.only=false
> > org.apache.zookeeper.server.quorum.QuorumPeerMain /etc/zookeeper/zoo.cfg
> >
> > This didn't work: log messages for those two classes are still coming
> out.
> > I tried with the lower case ("warn" instead of "WARN") and that didn't
> work
> > either
> >
> > Further playing around with setting zookeeper.root.logger to ERROR makes
> me
> > wonder if zookeeper is honoring these command line parameters at all
> >
> > I don't see any reference to a log4j.properties, and running it under
> > strace tells me its not opening a log4j file anywhere.
> >
> > any ideas?
> >
>

Re: turning off per class logging

Posted by Luke Stephenson <lu...@gmail.com>.
Hello,

This is some general feedback, nothing specific to zookeeper.

Where in the log4j documentation does it say you can set the log level per
class as a jvm property?  I've not seen this before and couldn't see it
when I looked through the documentation.
http://logging.apache.org/log4j/2.x/manual/configuration.html#SystemProperties
.

I'd suggest using a log4j xml configuration file as documented here
http://logging.apache.org/log4j/2.x/manual/configuration.html

Luke

On 24 February 2015 at 04:01, Ben Hsu <be...@criticalmedia.com> wrote:

> Hello
>
> I wish to suppress zookeeper logging at the class level. I see a lot of
> messages in my log along these lines:
>
> 2015-02-23 16:54:53,192 - INFO  [NIOServerCxn.Factory:/0.0.0.0:2181
> :NIOServerCnxnFactory@197] - Accepted socket connection from /
> 127.0.0.1:37142
> 2015-02-23 16:54:53,202 - INFO  [NIOServerCxn.Factory:/0.0.0.0:2181
> :NIOServerCnxn@827] - Processing srvr command from /127.0.0.1:37142
> 2015-02-23 16:54:53,205 - INFO  [Thread-3:NIOServerCnxn@1007] - Closed
> socket connection for client /127.0.0.1:37142 (no session established for
> client)
> 2015-02-23 16:54:53,234 - INFO  [NIOServerCxn.Factory:/0.0.0.0:2181
> :NIOServerCnxnFactory@197] - Accepted socket connection from /
> 127.0.0.1:37143
> 2015-02-23 16:54:53,235 - INFO  [NIOServerCxn.Factory:/0.0.0.0:2181
> :NIOServerCnxn@827] - Processing wchs command from /127.0.0.1:37143
> 2015-02-23 16:54:53,237 - INFO  [Thread-4:NIOServerCnxn@1007] - Closed
> socket connection for client /127.0.0.1:37143 (no session established for
> client)
>
>
> I want to set logging for the NIOServerCnxn and NIOServerCnxnFactory
> classes to WARN, but keep everything else at the INFO level. How can I do
> this?
>
> I tried to set log4j properties at the class level:
>
> java -Dlog4j.logger.org.apache.zookeeper.server.NIOServerxnFactory=WARN
> -Dlog4j.logger.org.apache.zookeeper.server.NIOServerCnxn=WARN
> -Dzookeeper.log.dir=/var/log/ -Dzookeeper.root.logger=CONSOLE -cp
>
> /etc/zookeeper::/usr/lib64/zookeeper/bin/../zookeeper-3.4.6.jar:/usr/lib64/zookeeper/bin/../lib/jline-0.9.94.jar:/usr/lib64/zookeeper/bin/../lib/log4j-1.2.16.jar:/usr/lib64/zookeeper/bin/../lib/netty-3.7.0.Final.jar:/usr/lib64/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/usr/lib64/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar
> -Dcom.sun.management.jmxremote
> -Dcom.sun.management.jmxremote.local.only=false
> org.apache.zookeeper.server.quorum.QuorumPeerMain /etc/zookeeper/zoo.cfg
>
> This didn't work: log messages for those two classes are still coming out.
> I tried with the lower case ("warn" instead of "WARN") and that didn't work
> either
>
> Further playing around with setting zookeeper.root.logger to ERROR makes me
> wonder if zookeeper is honoring these command line parameters at all
>
> I don't see any reference to a log4j.properties, and running it under
> strace tells me its not opening a log4j file anywhere.
>
> any ideas?
>