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"><<a href="mailto:ceki@qos.ch">ceki@qos.ch</a>></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 <<a href="mailto:lance.white@logicscope.com" target="_blank">lance.white@logicscope.com</a><br></div><div><div></div><div class="h5">
<mailto:<a href="mailto:lance.white@logicscope.com" target="_blank">lance.white@logicscope.com</a>>> wrote:<br>
<br>
>> However, when I try to use this code outside of my test<br>
environement, I get the following Exception on the first line:<br>
>> java.lang.ClassCastException:<br>
ch.qos.logback.classic.LoggerContext cannot be cast to<br>
ch.qos.logback.classic.LoggerContext<br>
<br>
This is usually a multiple classloader problem.<br>
<br>
Lance<br>
<br>
*From:*<a href="mailto:logback-user-bounces@qos.ch" target="_blank">logback-user-bounces@qos.ch</a><br>
<mailto:<a href="mailto:logback-user-bounces@qos.ch" target="_blank">logback-user-bounces@qos.ch</a>><br>
[mailto:<a href="mailto:logback-user-bounces@qos.ch" target="_blank">logback-user-bounces@qos.ch</a><br>
<mailto:<a href="mailto:logback-user-bounces@qos.ch" target="_blank">logback-user-bounces@qos.ch</a>>] *On Behalf Of *Clemens Siebler<br>
*Sent:* 24 March 2011 16:16<br>
*To:* logback users list<br>
*Subject:* Re: [logback-user] Retrieving the log filenames<br>
<br>
Ok, I figured out how to get at least the base logfile:<br>
LoggerContext ctx = (LoggerContext)<br>
LoggerFactory.getILoggerFactory();<br>
for (Logger l : ctx.getLoggerList()) {<br>
ch.qos.logback.classic.Logger log =<br>
(ch.qos.logback.classic.Logger) l;<br>
Iterator<Appender<ILoggingEvent>> it =<br>
log.iteratorForAppenders();<br>
while (it.hasNext()) {<br>
Appender<ILoggingEvent> ap = it.next();<br>
if (ap instanceof FileAppender<?> || ap instanceof<br>
RollingFileAppender<?>) {<br>
FileAppender<?> fileAppender = (FileAppender<?>)ap;<br>
System.out.println(fileAppender.getFile());<br>
}<br>
}<br>
}<br>
<br>
However, when I try to use this code outside of my test<br>
environement, I get the following Exception on the first line:<br>
java.lang.ClassCastException: ch.qos.logback.classic.LoggerContext<br>
cannot be cast to ch.qos.logback.classic.LoggerContext<br>
<br>
Any ideas? I'm currently using Jetty, slf4j and logback. However, it<br>
seems that there are still some dependencies on log4j in Jetty that<br>
I can't get rid of...<br>
<br>
On Tue, Mar 22, 2011 at 10:23 AM, Clemens Siebler<br>
<<a href="mailto:clemens.siebler@googlemail.com" target="_blank">clemens.siebler@googlemail.com</a><br></div></div><div class="im">
<mailto:<a href="mailto:clemens.siebler@googlemail.com" target="_blank">clemens.siebler@googlemail.com</a>>> wrote:<br>
<br>
As far as log4j goes, the getAppender function can be used. However,<br>
I have not managed to get this one working for logback. Any ideas?<br>
<br>
On Mon, Mar 21, 2011 at 3:42 PM, Clemens Siebler<br>
<<a href="mailto:clemens.siebler@googlemail.com" target="_blank">clemens.siebler@googlemail.com</a><br></div><div class="im">
<mailto:<a href="mailto:clemens.siebler@googlemail.com" target="_blank">clemens.siebler@googlemail.com</a>>> wrote:<br>
<br>
Let's assume the user only changes the logging levels/filter during<br>
runtime, nothing else.<br>
<br>
On Mon, Mar 21, 2011 at 3:32 PM, David Roussel<br></div>
<<a href="mailto:nabble@diroussel.xsmail.com" target="_blank">nabble@diroussel.xsmail.com</a> <mailto:<a href="mailto:nabble@diroussel.xsmail.com" target="_blank">nabble@diroussel.xsmail.com</a>>><div class="im">
<br>
wrote:<br>
<br>
Would a change notifier be told of the new filename? I'm not sure,<br>
but it's worth a check.<br>
<br>
<br>
On 21 Mar 2011, at 13:56, Clemens Siebler<br>
<<a href="mailto:clemens.siebler@googlemail.com" target="_blank">clemens.siebler@googlemail.com</a><br></div><div class="im">
<mailto:<a href="mailto:clemens.siebler@googlemail.com" target="_blank">clemens.siebler@googlemail.com</a>>> wrote:<br>
<br>
> Hi all,<br>
><br>
> I'm currently using Logback (SLF4J) with a TimeBasedRollingPolicy<br>
defined in logback.xml. Everything works fine, however, I'd like to<br>
retrieve the filenames of the current logging session since the<br>
application started. The user can obviously change the log filenames<br>
and policies in logback.xml, so I don't want them hardcoded in the<br>
source. My goal is to retrieve these filenames straight within Java<br>
in order to do some more processing with them. Is there any<br>
possibility in logback/slf4j to retrieve those names?<br>
><br>
> I currently aquire the logger via:<br>
> Logger logger = LoggerFactory.getLogger(Test.class);<br>
><br>
> but obviously, this Logger object in particular doesn't provide<br>
such functionality. Any ideas?<br>
><br>
> Thanks in advance,<br>
> 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>