log4j: Change format of loggers configured in another library.
Posted
by Ignacio Thayer
on Stack Overflow
See other posts from Stack Overflow
or by Ignacio Thayer
Published on 2010-04-23T00:36:29Z
Indexed on
2010/04/23
0:43 UTC
Read the original article
Hit count: 283
Using clojure, I've been able to successfully setup log4j very simply by using this log4j.properties file, and including log4j in my classpath.
# BEGIN log4j.properties
log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender
log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout
log4j.appender.STDOUT.layout.ConversionPattern=%d{MMdd HHmmss SSS} %5p %c [%t] %m\n
log4j.rootLogger=DEBUG, STDOUT
Then after :use'ing clojure.contrib.logging, I'm able to print a statement with the desired formatting as expected like so:
(info "About to print this")
(debug "This is debug-level")
My question is how to achieve a consistent formatting for logging statements made from loggers configured in other libraries. I thought I could find existing loggers using org.apache.log4j.LogManager.getCurrentLoggers() and change the PatternLayouts there, but I'm not able to iterate over that enumeration in clojure, as I get the following error:
Dont know how to create ISeq from: java.util.Vector$1
I assume this is possible somehow, and probably very simply. How?
Thanks much.
© Stack Overflow or respective owner