通过log4j关闭memcached的日志

在使用java API使用memcached时,日志会自动打印,关闭方式可参考其官方文档,如下

http://code.google.com/p/spymemcached/wiki/Logging

Using log4j

Set the logger impl to net.spy.log.Log4JLogger. For example:

  -Dnet.spy.log.LoggerImpl=net.spy.memcached.compat.log.Log4JLogger 

Using Java's Built-in Logging

Set the logger impl to net.spy.memcached.compat.log.SunLogger. For example:

  -Dnet.spy.log.LoggerImpl=net.spy.memcached.compat.log.SunLogger


具体到log4j的实际操作方式为:

在tomcat bin下简历setenv.sh

里面写上:

L4J_OPTS="-Dnet.spy.log.LoggerImpl=net.spy.memcached.compat.log.Log4JLogger"
JVM_OPTS=""
CATALINA_OPTS="${JVM_OPTS} ${L4J_OPTS}"

在log4j中关闭net或者更精确的方式,如:

log4j.logger.net = error, stdout

log4j.logger.net.spy.memcached.transcoders.SerializingTranscoder = error,stdout


即可。

你可能感兴趣的:(通过log4j关闭memcached的日志)