Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #12823
| Date | 2012-03-09 21:14 -0500 |
|---|---|
| From | Arne Vajhøj <arne@vajhoej.dk> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: SimpleFormatter Question |
| References | <XnsA011D2474C732jpnasty@94.75.214.39> |
| Message-ID | <4f5ab90d$0$289$14726298@news.sunsite.dk> (permalink) |
| Organization | SunSITE.dk - Supporting Open source |
On 3/9/2012 8:40 PM, Novice wrote: > 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. Are you using Java 7? The docs are for Java 7 and that property does not seem to work for Java 6. Arne
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
SimpleFormatter Question Novice <novice@example..com> - 2012-03-10 01:40 +0000
Re: SimpleFormatter Question Arne Vajhøj <arne@vajhoej.dk> - 2012-03-09 21:14 -0500
Re: SimpleFormatter Question Novice <novice@example..com> - 2012-03-10 04:45 +0000
Re: SimpleFormatter Question Novice <novice@example..com> - 2012-03-10 04:57 +0000
Re: SimpleFormatter Question Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-03-10 09:26 -0400
Re: SimpleFormatter Question Novice <novice@example..com> - 2012-03-10 17:55 +0000
Re: SimpleFormatter Question Lew <noone@lewscanon.com> - 2012-03-10 10:27 -0800
Re: SimpleFormatter Question Novice <novice@example..com> - 2012-03-10 20:47 +0000
Re: SimpleFormatter Question Arne Vajhøj <arne@vajhoej.dk> - 2012-03-10 12:08 -0500
csiph-web