Change global setting for Logger instances

前端 未结 5 883
小蘑菇
小蘑菇 2020-11-30 01:54

I\'m using java.util.logging.Logger as the logging engine for my application. Each class uses it\'s own logger, i.e., each class has:

private final Logger lo         


        
5条回答
  •  执念已碎
    2020-11-30 02:19

    One easy way is to use a logging properties file, by including this VM argument:

    -Djava.util.logging.config.file="logging.properties" 
    

    where "logging.properties" is the path to a file containing logging configuration. For relative paths, the working directory of the process is significant.

    In that file, include a line like this:

    .level= INFO
    

    This sets the global level, which can be overridden for specific handlers and loggers. For example, a specific logger's level can be overridden like this:

     com.xyz.foo.level = SEVERE
    

    You can get a template for a logging properties file from jre6\lib\logging.properties.

提交回复
热议问题