下列範例說明如何在 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