N
Novice
I'm experimenting with java.util.logging.SimpleFormatter and I've run
into a problem.
The API
(http://docs.oracle.com/javase/7/docs/api/java/util/logging/SimpleFormatt
er.html) says that you can control the format of a simple log via the
java.util.logging.SimpleFormatter.format property; a bunch of variables
are available as the value of the property. I put this value, copied
right out of the API, in my logging.properties:
java.util.logging.SimpleFormatter.format="%4$s: %5$s [%1$tc]%n"
This is supposed to yield a message that looks like this:
WARNING: warning message [Tue Mar 22 13:11:31 PDT 2011]
When I run my program though, the output looks like this:
9-Mar-2012 6:09:32 PM com.novice.common.LocalizationUtils getResources
SEVERE: The base name cannot be null.
In other words, the format I've specified is completely ignored.
What's the trick to make the program use the format I've specified? I'm
confident that the logging.properties file I've specified in my VM
argument is being used because it is naming my log file correctly. I'm
having trouble thinking of any other reason why this isn't working. Here
is my config file with all the comments stripped out.
========================================================================
handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
..level= ALL
java.util.logging.FileHandler.pattern = %h/Foo%u.log
java.util.logging.FileHandler.limit = 50000
java.util.logging.FileHandler.count = 1
java.util.logging.FileHandler.formatter =
java.util.logging.SimpleFormatter
java.util.logging.SimpleFormatter.format = "%4$s: %5$s [%1$tc]%n"
java.util.logging.FileHandler.level = ALL
java.util.logging.ConsoleHandler.level = INFO
java.util.logging.ConsoleHandler.formatter =
java.util.logging.SimpleFormatter
com.novice.foo.level = ALL
java.level = WARNING
sun.level = WARNING
javax.level = WARNING
========================================================================
I can't see anything in the API that explains this and Google may be my
friend but it isn't helping me sort this out.
into a problem.
The API
(http://docs.oracle.com/javase/7/docs/api/java/util/logging/SimpleFormatt
er.html) says that you can control the format of a simple log via the
java.util.logging.SimpleFormatter.format property; a bunch of variables
are available as the value of the property. I put this value, copied
right out of the API, in my logging.properties:
java.util.logging.SimpleFormatter.format="%4$s: %5$s [%1$tc]%n"
This is supposed to yield a message that looks like this:
WARNING: warning message [Tue Mar 22 13:11:31 PDT 2011]
When I run my program though, the output looks like this:
9-Mar-2012 6:09:32 PM com.novice.common.LocalizationUtils getResources
SEVERE: The base name cannot be null.
In other words, the format I've specified is completely ignored.
What's the trick to make the program use the format I've specified? I'm
confident that the logging.properties file I've specified in my VM
argument is being used because it is naming my log file correctly. I'm
having trouble thinking of any other reason why this isn't working. Here
is my config file with all the comments stripped out.
========================================================================
handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
..level= ALL
java.util.logging.FileHandler.pattern = %h/Foo%u.log
java.util.logging.FileHandler.limit = 50000
java.util.logging.FileHandler.count = 1
java.util.logging.FileHandler.formatter =
java.util.logging.SimpleFormatter
java.util.logging.SimpleFormatter.format = "%4$s: %5$s [%1$tc]%n"
java.util.logging.FileHandler.level = ALL
java.util.logging.ConsoleHandler.level = INFO
java.util.logging.ConsoleHandler.formatter =
java.util.logging.SimpleFormatter
com.novice.foo.level = ALL
java.level = WARNING
sun.level = WARNING
javax.level = WARNING
========================================================================
I can't see anything in the API that explains this and Google may be my
friend but it isn't helping me sort this out.