how can i display the fine log message in output screen in java?
Asked
Active
Viewed 1,393 times
2
-
2See related question: http://stackoverflow.com/questions/470430/java-util-logging-logger-doesnt-respect-java-util-logging-level – Kevin Crowell Aug 24 '10 at 06:15
1 Answers
1
You might want to configure other defaults with a properties file. This allow things to be reconfigured without recompiling.
# 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
I prefer this to littering my code with logging configuration calls.
You have to specify the location of the file with a command line option though :
java -Djava.util.logging.config.file=mylogging.properties
I personally always use log4j or slf4j because it looks for a config file in the classpath. Well, maybe java.util.logging does that too, I never really investigated.

Peter Tillemans
- 34,983
- 11
- 83
- 114