<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>You probably don't want commons logging on your classpath. &nbsp;See here:&nbsp;<a href="http://www.slf4j.org/legacy.html">http://www.slf4j.org/legacy.html</a></div><div><br></div><br><div><div>On 29 Mar 2011, at 13:53, Clemens Siebler wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Thanks Ceki, that could be the issue. I currently have a bunch of jars in my classpath, that all have to do with logging:<br><br>commons-logging-api.jar<br>commons-logging.jar<br>log4j.jar<br>logback-classic-0.9.21.jar<br>
logback-core-0.9.21.jar <br>slf4j-api-1.6.1.jar<br><br>I use Jetty+Spring Framework and the latter one requires Log4j and the commons-logging jars. The part of the application that I wrote, only uses Logback+Slf4j. Any ideas how to get away with this?<br>
<br><br><div class="gmail_quote">On Tue, Mar 29, 2011 at 2:32 PM, Ceki Gulcu <span dir="ltr">&lt;<a href="mailto:ceki@qos.ch">ceki@qos.ch</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hello Clemens,<br>
<br>
Lance's suggestion is almost certaint on target. Do check your classpath to see if there are multiple instances of logback-classic lying around.<br>
--<br>
Ceki<div class="im"><br>
On 29.03.2011 14:13, Clemens Siebler wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
Thanks for the hint Lance! I feel like this could be the issue. However,<br>
I haven't managed to actually find a solution to it. I tried starting my<br>
application with -verbose:class, but I can only see one entry of:<br>
[Loaded ch.qos.logback.classic.LoggerContext from<br>
file:/yyy/logback-classic-0.9.21.jar]. I suppose there should be<br>
multiple of these, if that actually is the problem? Thanks for your help!<br>
<br>
<br>
On Fri, Mar 25, 2011 at 4:54 PM, Lance White &lt;<a href="mailto:lance.white@logicscope.com" target="_blank">lance.white@logicscope.com</a><br></div><div><div></div><div class="h5">
&lt;mailto:<a href="mailto:lance.white@logicscope.com" target="_blank">lance.white@logicscope.com</a>&gt;&gt; wrote:<br>
<br>
 &nbsp; &nbsp; &gt;&gt; However, when I try to use this code outside of my test<br>
 &nbsp; &nbsp;environement, I get the following Exception on the first line:<br>
 &nbsp; &nbsp; &gt;&gt; java.lang.ClassCastException:<br>
 &nbsp; &nbsp;ch.qos.logback.classic.LoggerContext cannot be cast to<br>
 &nbsp; &nbsp;ch.qos.logback.classic.LoggerContext<br>
<br>
 &nbsp; &nbsp;This is usually a multiple classloader problem.<br>
<br>
 &nbsp; &nbsp;Lance<br>
<br>
 &nbsp; &nbsp;*From:*<a href="mailto:logback-user-bounces@qos.ch" target="_blank">logback-user-bounces@qos.ch</a><br>
 &nbsp; &nbsp;&lt;mailto:<a href="mailto:logback-user-bounces@qos.ch" target="_blank">logback-user-bounces@qos.ch</a>&gt;<br>
 &nbsp; &nbsp;[mailto:<a href="mailto:logback-user-bounces@qos.ch" target="_blank">logback-user-bounces@qos.ch</a><br>
 &nbsp; &nbsp;&lt;mailto:<a href="mailto:logback-user-bounces@qos.ch" target="_blank">logback-user-bounces@qos.ch</a>&gt;] *On Behalf Of *Clemens Siebler<br>
 &nbsp; &nbsp;*Sent:* 24 March 2011 16:16<br>
 &nbsp; &nbsp;*To:* logback users list<br>
 &nbsp; &nbsp;*Subject:* Re: [logback-user] Retrieving the log filenames<br>
<br>
 &nbsp; &nbsp;Ok, I figured out how to get at least the base logfile:<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LoggerContext ctx = (LoggerContext)<br>
 &nbsp; &nbsp;LoggerFactory.getILoggerFactory();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (Logger l : ctx.getLoggerList()) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ch.qos.logback.classic.Logger log =<br>
 &nbsp; &nbsp;(ch.qos.logback.classic.Logger) l;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Iterator&lt;Appender&lt;ILoggingEvent&gt;&gt; it =<br>
 &nbsp; &nbsp;log.iteratorForAppenders();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while (it.hasNext()) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Appender&lt;ILoggingEvent&gt; ap = it.next();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (ap instanceof FileAppender&lt;?&gt; || ap instanceof<br>
 &nbsp; &nbsp;RollingFileAppender&lt;?&gt;) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FileAppender&lt;?&gt; fileAppender = (FileAppender&lt;?&gt;)ap;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(fileAppender.getFile());<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>
<br>
 &nbsp; &nbsp;However, when I try to use this code outside of my test<br>
 &nbsp; &nbsp;environement, I get the following Exception on the first line:<br>
 &nbsp; &nbsp;java.lang.ClassCastException: ch.qos.logback.classic.LoggerContext<br>
 &nbsp; &nbsp;cannot be cast to ch.qos.logback.classic.LoggerContext<br>
<br>
 &nbsp; &nbsp;Any ideas? I'm currently using Jetty, slf4j and logback. However, it<br>
 &nbsp; &nbsp;seems that there are still some dependencies on log4j in Jetty that<br>
 &nbsp; &nbsp;I can't get rid of...<br>
<br>
 &nbsp; &nbsp;On Tue, Mar 22, 2011 at 10:23 AM, Clemens Siebler<br>
 &nbsp; &nbsp;&lt;<a href="mailto:clemens.siebler@googlemail.com" target="_blank">clemens.siebler@googlemail.com</a><br></div></div><div class="im">
 &nbsp; &nbsp;&lt;mailto:<a href="mailto:clemens.siebler@googlemail.com" target="_blank">clemens.siebler@googlemail.com</a>&gt;&gt; wrote:<br>
<br>
 &nbsp; &nbsp;As far as log4j goes, the getAppender function can be used. However,<br>
 &nbsp; &nbsp;I have not managed to get this one working for logback. Any ideas?<br>
<br>
 &nbsp; &nbsp;On Mon, Mar 21, 2011 at 3:42 PM, Clemens Siebler<br>
 &nbsp; &nbsp;&lt;<a href="mailto:clemens.siebler@googlemail.com" target="_blank">clemens.siebler@googlemail.com</a><br></div><div class="im">
 &nbsp; &nbsp;&lt;mailto:<a href="mailto:clemens.siebler@googlemail.com" target="_blank">clemens.siebler@googlemail.com</a>&gt;&gt; wrote:<br>
<br>
 &nbsp; &nbsp;Let's assume the user only changes the logging levels/filter during<br>
 &nbsp; &nbsp;runtime, nothing else.<br>
<br>
 &nbsp; &nbsp;On Mon, Mar 21, 2011 at 3:32 PM, David Roussel<br></div>
 &nbsp; &nbsp;&lt;<a href="mailto:nabble@diroussel.xsmail.com" target="_blank">nabble@diroussel.xsmail.com</a> &lt;mailto:<a href="mailto:nabble@diroussel.xsmail.com" target="_blank">nabble@diroussel.xsmail.com</a>&gt;&gt;<div class="im">
<br>
 &nbsp; &nbsp;wrote:<br>
<br>
 &nbsp; &nbsp;Would a change notifier be told of the new filename? &nbsp;I'm not sure,<br>
 &nbsp; &nbsp;but it's worth a check.<br>
<br>
<br>
 &nbsp; &nbsp;On 21 Mar 2011, at 13:56, Clemens Siebler<br>
 &nbsp; &nbsp;&lt;<a href="mailto:clemens.siebler@googlemail.com" target="_blank">clemens.siebler@googlemail.com</a><br></div><div class="im">
 &nbsp; &nbsp;&lt;mailto:<a href="mailto:clemens.siebler@googlemail.com" target="_blank">clemens.siebler@googlemail.com</a>&gt;&gt; wrote:<br>
<br>
 &nbsp; &nbsp; &gt; Hi all,<br>
 &nbsp; &nbsp; &gt;<br>
 &nbsp; &nbsp; &gt; I'm currently using Logback (SLF4J) with a TimeBasedRollingPolicy<br>
 &nbsp; &nbsp;defined in logback.xml. Everything works fine, however, I'd like to<br>
 &nbsp; &nbsp;retrieve the filenames of the current logging session since the<br>
 &nbsp; &nbsp;application started. The user can obviously change the log filenames<br>
 &nbsp; &nbsp;and policies in logback.xml, so I don't want them hardcoded in the<br>
 &nbsp; &nbsp;source. My goal is to retrieve these filenames straight within Java<br>
 &nbsp; &nbsp;in order to do some more processing with them. Is there any<br>
 &nbsp; &nbsp;possibility in logback/slf4j to retrieve those names?<br>
 &nbsp; &nbsp; &gt;<br>
 &nbsp; &nbsp; &gt; I currently aquire the logger via:<br>
 &nbsp; &nbsp; &gt; Logger logger = LoggerFactory.getLogger(Test.class);<br>
 &nbsp; &nbsp; &gt;<br>
 &nbsp; &nbsp; &gt; but obviously, this Logger object in particular doesn't provide<br>
 &nbsp; &nbsp;such functionality. Any ideas?<br>
 &nbsp; &nbsp; &gt;<br>
 &nbsp; &nbsp; &gt; Thanks in advance,<br>
 &nbsp; &nbsp; &gt; Clemens<br>
</div></blockquote><div><div></div><div class="h5">
<br>
<br>
_______________________________________________<br>
Logback-user mailing list<br>
<a href="mailto:Logback-user@qos.ch" target="_blank">Logback-user@qos.ch</a><br>
<a href="http://qos.ch/mailman/listinfo/logback-user" target="_blank">http://qos.ch/mailman/listinfo/logback-user</a><br>
</div></div></blockquote></div><br>
_______________________________________________<br>Logback-user mailing list<br><a href="mailto:Logback-user@qos.ch">Logback-user@qos.ch</a><br>http://qos.ch/mailman/listinfo/logback-user<br></blockquote></div><br></body></html>