如何禁用类或整个包的记录器? [英] How to disable loggers of a class or of whole package?

查看:91
本文介绍了如何禁用类或整个包的记录器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用apache.commons.logging,现在我想使用SimpleLog实现,但是当更改级别时,来自库的记录器就会出现。我想把它关掉。
有没有一种简单的方法来改变整个包的日志级别(可以log4j这样做)?

我试图设置

I am using apache.commons.logging, for now I wanted to use SimpleLog implementation, but when changed the level, loggers from libraries come out. I want it to turn it off. Is there a easy way to change log level for whole package (Can log4j do that) ?
I have tried to set


org.apache.commons.logging.simplelog.log.foo =致命

org.apache.commons.logging.simplelog.log.foo=fatal

在simplelog属性文件中禁用(设置为致命可以)foo记录器,但它不起作用。 (foo是输出中出现的记录器的名称:[INFO] foo - 消息)。

in simplelog property files to disable (setting to fatal is OK) foo logger, but it doesn't works. (foo is a name of logger that appears in output : [INFO] foo - Message).

推荐答案

在Log4j中,您可以指定由字符串标识的指定包,类或记录器的日志记录级别。你只需在log4j.properties文件中写这个:

In Log4j you can specify a logging level for specified package, class or logger identified by string. You just simply write this in log4j.properties file:

log4j.logger.<your package> = DEBUG|INFO|OFF|WARN...

这篇关于如何禁用类或整个包的记录器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆