开发者

How to make logging.properties and commons-logging.properties property files working?

开发者 https://www.devze.com 2023-02-09 23:55 出处:网络
I have two property files in my default package (I\'m using NetBeans): commons-logging.properties with property:

I have two property files in my default package (I'm using NetBeans):

commons-logging.properties with property:

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

and logging.properties with:开发者_Go百科

handlers=java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level=SEVERE

java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter

I'm getting INFO level messages in output. What i'm doing wrong? I also haven't found any information about JDK configuration, just example as above.


How are you calling the java?

Are you putting -Djava.util.logging.config.file=/logging.properties in your java command?

If not, it would ignore your logging.properties and log everything.

.level=ALL on a line of it's own is used as a global level, e.g. : -

handlers=java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level=INFO
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
.level=SEVERE
mypackage.level=INFO

would only log INFO messages from mypackage and SEVERE from everything else.


I'm not sure why you have .level=SEVERE appended on the last line, it should just like this:-

handlers=java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level=SEVERE
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
0

精彩评论

暂无评论...
验证码 换一张
取 消