以下示例说明了如何在 JRE_DIRECTORY/lib/logging.properties 文件(用于设置 Java 运行环境的日志级别)中设置日志记录的名称空间和级别。使用此 JRE 的所有应用程序都将具有相同的日志记录配置。下面的样例配置将 javax.jms.connection 名称空间的日志记录级别设置为 INFO,并指定将输出写入 java.util.logging.ConsoleHandler。
#logging.properties file. # "handlers" specifies a comma separated list of log Handler # classes. These handlers will be installed during VM startup. # Note that these classes must be on the system classpath. # By default we only configure a ConsoleHandler, which will only # show messages at the INFO and above levels. handlers= java.util.logging.ConsoleHandler # Default global logging level. # This specifies which kinds of events are logged across # all loggers. For any given facility this global level # can be overriden by a facility-specific level. # Note that the ConsoleHandler also has a separate level # setting to limit messages printed to the console. .level= INFO # Limit the messages that are printed on the console to INFO and above. java.util.logging.ConsoleHandler.level = INFO java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter # The logger with javax.jms.connection name space will write # Level.INFO messages to its output handler(s). In this configuration # the ouput handler is set to java.util.logging.ConsoleHandler. javax.jms.connection.level = INFO