|
How to configure a logger default values with a properties file |
|
|
This Java tip illustrates a method of configuring a logger default values with
a properties file. Developer may get more information about logging properties in
the lib/logging.properties file in the JRE directory.
# Specify the handlers to create in the root logger
# (all loggers are children of the root logger)
# The following creates two handlers
handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler
# Set the default logging level for the root logger
.level = ALL
# Set the default logging level for new ConsoleHandler instances
java.util.logging.ConsoleHandler.level = INFO
# Set the default logging level for new FileHandler instances
java.util.logging.FileHandler.level = ALL
# Set the default formatter for new ConsoleHandler instances
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
# Set the default logging level for the logger named com.mycompany
com.mycompany.level = ALL
|
The custom logging properties file is loaded by specifying a system property on
the command line:
java -Djava.util.logging.config.file=mylogging.properties <class>
|
Related Tips
|
Page 1 of 0 ( 0 comments )
You can share your information about this topic using the form below!
Please do not post your questions with this form! Thanks.