Thursday, July 14, 2005
Default log4j configuration?
Something that really annoys me is how log4j behaves when there's no "log4j.properties" or "log4j.xml" in the classpath.
Instead of printing out my log statements to System.out I simply get:
When discovering that there is no user-provided configuration, log4j would use a "fall-back" configuration instead (say, "default-log4j.properties" from the log4j.jar file). The content of such a file would be something really simple such as:
Update: There's a version 1.3 of log4j that's supposed to be released at some point. Does anyone know if this feature (or something similar) will be included in that release?
Instead of printing out my log statements to System.out I simply get:
log4j:WARN No appenders could be found for logger (com.foo.Bar).Wouldn't it be nice if log4j could provide a default configuration instead?
log4j:WARN Please initialize the log4j system properly.
When discovering that there is no user-provided configuration, log4j would use a "fall-back" configuration instead (say, "default-log4j.properties" from the log4j.jar file). The content of such a file would be something really simple such as:
log4j.rootLogger=DEBUG, Console
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
Update: There's a version 1.3 of log4j that's supposed to be released at some point. Does anyone know if this feature (or something similar) will be included in that release?
Comments:
<< Home
I agree about the problem.
submitting code to log4j would be like writing it on toilet paper and flushing it down the toilet.
submitting code to log4j would be like writing it on toilet paper and flushing it down the toilet.
The message is helpful if you think you have set the properties, and for some reason Log4J doesn't pick them up (i.e., you put the configuration file in the wrong place).
A nice medium would be to display the warning, say you are using default, then just log to stdout.
A nice medium would be to display the warning, say you are using default, then just log to stdout.
Yeah, the behaviour you describe is the most sensible IMO as well.
About the log4j team not being likely to accept a patch - is this really true?
About the log4j team not being likely to accept a patch - is this really true?
Ciao Blogger ! Hai creato veramente un bellissimo blog, complimenti! Vorrei segnalarti il mio sito che si occupa di scommesse online . Solo scommesse online !
I must congratulate with you Blogger because of this wonderful blog! It's really full of informations! Maybe you could be interested in having a look to my internet site that includes informations about scommesse ... if you are interested in scommesse it's the right place for you!
Post a Comment
<< Home


