为什么apache.commons.logging.Log不会loggingdebugging级别?

我有一个J2SE桌面应用程序,我试图了解如何使用Apache公共日志logging。 我在我的项目中有以下属性文件,使用最新的Apache公共日志logging:

commons-logging.properties:

org.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger #Priorities are: DEBUG, INFO, WARN, ERROR, or FATAL. log4j.rootCategory=DEBUG log4j.appender.appender.Threshold=DEBUG 

log4j.properties:

 log4j.rootLogger=TRACE 

logging.properties:

 # jdk handlers handlers=java.util.logging.ConsoleHandler java.util.logging.FileHandler # default log level FINE=ERROR FINER= FINEST= .level=FINEST java.util.logging.ConsoleHandler.level=FINEST # log file name for the FileHandler java.util.logging.FileHandler.pattern=gef_debug.log 

甚至一切设置为FINEST或TRACE,我仍然只是在我的控制台上的信息和错误日志。

任何想法这里有什么问题?

顺便说一下,我在一个现有的旧项目,所以也许有一些我不知道的configuration,这是阻止我的日志…:/但只用于DEBUG级别。

org.apache.commons.logging.Log= org.apache.commons.logging.impl.Jdk14Logger

我认为这行意味着你正在使用Jdk14Logger,而不是Log4j

Jdk14Logger读取文件log-config.properties 。 只需在应用程序类路径中创建它并进行设置即可。 例如:

 # The following creates the console handler handlers=java.util.logging.ConsoleHandler # Set the default logging level for the root logger .level=FINEST # Set the default logging level java.util.logging.ConsoleHandler.level=ALL # Set the default formatter java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter 

您还可以通过将commons-logging.properties的第一行更改org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger将记录器更改为Log4j。

通过这样做,您将使用从log4j.properties中读取的Log4J记录器,因此您需要将控制台处理程序添加到该记录器中。

你可以看看这里的几个日志实现。