logback.xml not working inside Ant task

Hi, I've got a library that uses Logback through slf4j. When I invoke methods directly logging works just fine, but when I invoke Ant tasks that, in turn, invoke those methods logback.xml isn't being found and the default configuration is being used. I am at a loss as to what is different between the two configurations. When I run under Ant getClass().getResourceAsStream("/logback.xml") finds the file just fine, yet LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); StatusPrinter.print(lc); prints out: 05:08:51,098 |-INFO in ch.qos.logback.classic.BasicConfigurator@5b8ff6b8 - Setting up default configuration. How do I debug this problem further in order to figure out what is going wrong? Thank you, Gili -- View this message in context: http://www.nabble.com/logback.xml-not-working-inside-Ant-task-tp19158480p191... Sent from the Logback User mailing list archive at Nabble.com.

Ceki, I wanted to discuss this with you on IRC but I see that #logback is now empty. Do you have any ideas on how I can begin to debug this problem? I'm at a loss. Thanks, Gili cowwoc wrote:
Hi,
I've got a library that uses Logback through slf4j. When I invoke methods directly logging works just fine, but when I invoke Ant tasks that, in turn, invoke those methods logback.xml isn't being found and the default configuration is being used.
I am at a loss as to what is different between the two configurations. When I run under Ant
getClass().getResourceAsStream("/logback.xml")
finds the file just fine, yet
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); StatusPrinter.print(lc);
prints out:
05:08:51,098 |-INFO in ch.qos.logback.classic.BasicConfigurator@5b8ff6b8 - Setting up default configuration.
How do I debug this problem further in order to figure out what is going wrong?
Thank you, Gili
-- View this message in context: http://www.nabble.com/logback.xml-not-working-inside-Ant-task-tp19158480p191... Sent from the Logback User mailing list archive at Nabble.com.

The "/" prefix in "/logback.xml" also looks suspicious... Try, getClass().getClassLoader().getResource("logback.xml"); or alternatively Thread.currentThread().getContextClassLoader().getResource("logback.xml"); HTH, Thorbjørn Ravn Andersen wrote:
cowwoc skrev den 26-08-2008 11:14:
getClass().getResourceAsStream("/logback.xml")
So the file must be in the classpath. How do you ensure that it is?
-- Ceki Gülcü

System.out.println("logback1=" + getClass().getClassLoader().getResource("logback.xml")); System.out.println("logback2=" + Thread.currentThread().getContextClassLoader().getResource("logback.xml")); gives me this output: logback1=jar:file:/C:/Users/Gili/Documents/blueeye/trunk/org/jace/release/lib/jace.jar!/logback.xml logback2=null Gili Ceki Gulcu-2 wrote:
The "/" prefix in "/logback.xml" also looks suspicious...
Try,
getClass().getClassLoader().getResource("logback.xml");
or alternatively
Thread.currentThread().getContextClassLoader().getResource("logback.xml");
HTH,
Thorbjørn Ravn Andersen wrote:
cowwoc skrev den 26-08-2008 11:14:
getClass().getResourceAsStream("/logback.xml")
So the file must be in the classpath. How do you ensure that it is?
-- Ceki Gülcü _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://qos.ch/mailman/listinfo/logback-user
-- View this message in context: http://www.nabble.com/logback.xml-not-working-inside-Ant-task-tp19158480p192... Sent from the Logback User mailing list archive at Nabble.com.

I've placed it in the default package in my JAR file. Gili Thorbjørn Ravn Andersen wrote:
cowwoc skrev den 26-08-2008 11:14:
getClass().getResourceAsStream("/logback.xml")
So the file must be in the classpath. How do you ensure that it is?
-- Thorbjørn Ravn Andersen "... plus... Tubular Bells!"
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://qos.ch/mailman/listinfo/logback-user
-- View this message in context: http://www.nabble.com/logback.xml-not-working-inside-Ant-task-tp19158480p192... Sent from the Logback User mailing list archive at Nabble.com.
participants (3)
-
Ceki Gulcu
-
cowwoc
-
Thorbjørn Ravn Andersen