Hi Jason,<br><br>I think you should<br><br>*  Make sure  JUL log requests go to slf4j by using jul-to-slf4j.<br>* Make sure slf4j uses log4j&#39;s implementation by using slf4j-log4j12.<br>* Keep log4j.jar on your classpath<br>
<br>All code that directly uses log4j can keep doing that.<br><br>regards,<br><br>Maarten<br><br>
<br><br><div class="gmail_quote">On Mon, Jun 29, 2009 at 4:00 AM, Jason Wang <span dir="ltr">&lt;<a href="mailto:jason.wang@bulletin.net">jason.wang@bulletin.net</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="h5">Jason Wang wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi all,<br>
<br>
I am brand new to this wonderful slf4j tool(started to read about it 2 hours ago) and from my understanding switching to it should be a pain free process.  However I ran into some problems.<br>
<br>
My project mainly uses log4j directly and it now depends on a 3rd party library which uses JUL as  its logging framework. I would like to make sure all the logs the 3rd party lib produces under the control of my log4j settings. After a quick search on Google, the best approach seems to be use the slf4j lib to bridge JUL to it and then tell slf4j to use log4j as its backing implementation.<br>

<br>
So my solution idea is:<br>
1.Delegating all of my log4j logging request to slf4j (by using log4j over slf4j and removing the log4j jar)<br>
2. Make sure  JUL log requests go to slf4j by using jul-to-slf4j.<br>
<br>
3. Make sure slf4j uses log4j&#39;s implementation by using lf4j-log4j12. So hopefully I get:<br>
  A: my log4j.xml settings still work.<br>
  B: the 3rd party lib&#39;s JUL logging requests end up going to log4j in the end.<br>
<br>
My steps are:<br>
<br>
1. comment out the dependency on log4j in my pom.xml, so the log4j.jar will no longer be in my webapp/lib<br>
<br>
2. introduce the following 3 dependencies.<br>
&lt;dependency&gt;<br>
        &lt;groupId&gt;org.slf4j&lt;/groupId&gt;<br>
        &lt;artifactId&gt;log4j-over-slf4j&lt;/artifactId&gt;<br>
        &lt;version&gt;1.5.8&lt;/version&gt;<br>
      &lt;/dependency&gt;<br>
          &lt;dependency&gt;<br>
          &lt;groupId&gt;org.slf4j&lt;/groupId&gt;<br>
          &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;<br>
          &lt;version&gt;1.5.8&lt;/version&gt;<br>
          &lt;scope&gt;test&lt;/scope&gt;<br>
      &lt;/dependency&gt;<br>
        &lt;dependency&gt;<br>
          &lt;groupId&gt;org.slf4j&lt;/groupId&gt;<br>
          &lt;artifactId&gt;jul-to-slf4j&lt;/artifactId&gt;<br>
          &lt;version&gt;1.5.8&lt;/version&gt;<br>
      &lt;/dependency&gt;<br>
<br>
After applying the changes, the project still builds, great. But it fails immediately on runtime:<br>
<br>
Spring complains that it could not initialize org.apache.log4j.logger. Detailed message:<br>
<br>
Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with name &#39;paypalRestService&#39; defined in file [/home/jasonw/dev/bulletin-paymentengine/target/classes/com/bulletin/paymentengine/api/paypal/rest/resource/PaypalRestService.class]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.apache.log4j.Logger:<br>

java.lang.NoClassDefFoundError: Could not initialize class org.apache.log4j.Logger<br>
  at com.bulletin.paymentengine.api.paypal.rest.resource.PaypalRestService.&lt;clinit&gt;(PaypalRestService.java:45) <br>
<br>
<br>
So, my questions are: will my solution work at all in theory? Is there anything wrong in my solution?<br>
How to fix this spring problem?<br>
<br>
<br>
Thanks alot.<br>
<br>
Jas<br>
<br>
<br>
_______________________________________________<br>
user mailing list<br>
<a href="mailto:user@slf4j.org" target="_blank">user@slf4j.org</a><br>
<a href="http://www.slf4j.org/mailman/listinfo/user" target="_blank">http://www.slf4j.org/mailman/listinfo/user</a><br>
</blockquote></div></div>
Just realized that log4j-over-slf4j.jar can not live together with slf4j-logj12.jar. .. So my approach will never work.<br>
<br>
So folks, what will be the best approach to my question(delegate JUL to log4j)?<br>
<br>
I guess on way to do it is to change my code from log4j to slf4j-api so I can still use jul-to-slf4j and slf4j-to-log4j. But that will not be pain free at all, will it?<br>
<br>
Thanks<br><font color="#888888">
<br>
Jason</font><div><div></div><div class="h5"><br>
_______________________________________________<br>
user mailing list<br>
<a href="mailto:user@slf4j.org" target="_blank">user@slf4j.org</a><br>
<a href="http://www.slf4j.org/mailman/listinfo/user" target="_blank">http://www.slf4j.org/mailman/listinfo/user</a><br>
</div></div></blockquote></div><br>