[slf4j-user] log4j-over-slf4j checks circular dependency too strict

Maarten Bosteels mbosteels.dns at gmail.com
Tue Aug 10 11:11:42 CEST 2010


Hi
You don't need slf4j at all to make tomcat 6 use log4j
See the tomcat docs.

Maarten

2010/8/10, Tom Liu <Tom.SH.Liu at morganstanley.com>:
> Hi Ceki,
>
> I opened the bug here: http://bugzilla.slf4j.org/show_bug.cgi?id=194
>
> Thank you very much,
> Tom
>
> On Tue, Aug 10, 2010 at 3:09 PM, Ceki Gulcu <ceki at qos.ch> wrote:
>> Hi Tom,
>>
>> Sounds reasonable. Would you open a bug report requesting the change you
>> describe? Thanks,
>>
>> On 10.08.2010 06:38, Tom Liu wrote:
>>>
>>> Hi guys,
>>>
>>> I think log4j-over-slf4j (as well as jcl bridges) checks circular
>>> dependency too strict.
>>> Even when slf4j-log4j12.jar is visible, it does not necessarily mean
>>> it will be picked up by slf4j-api as the logging backend.
>>>
>>> Here is a setup in tomcat 6 demonstrate the issue:
>>> tomcat container lib contains: jcl-over-slf4j.jar, slf4j-api.jar,
>>> slf4j-log4j12.jar, log4j.jar
>>> Webapp WEB-INF/lib contains: log4j.jar, log4j-over-slf4j.jar,
>>> slf4j-api.jar, logback-core.jar, logback-access.jar.
>>> What we want to achieve is that tomcat logging (from commons-logging)
>>> will be routed to log4j and webapp's logging (from log4j) will be
>>> routed to logback.
>>> In theory, there will be no circular dependencies in runtime as
>>> logback is picked up as the logging backend. However, webapp failed to
>>> start because the "potential" circular dependency is detected.
>>>
>>> Is it possible to change the circular dependency detection algorithm
>>> to test against the actual binding picked up? I did a hack on
>>> org.apache.log4j.Log4jLoggerFactory which works for me:
>>> class Log4jLoggerFactory {
>>> ...
>>>
>>> static {
>>>
>>>         LoggerFactoryBinder binder = StaticLoggerBinder.getSingleton();
>>>         if
>>> ("org.slf4j.impl.Log4jLoggerFactory".equals(binder.getLoggerFactoryClassStr()))
>>> {
>>>             String part1 = "Detected both log4j-over-slf4j.jar AND
>>> slf4j-log4j12.jar on the class path, preempting StackOverflowError.
>>> REPLACED ";
>>>             String part2 = "See also " + LOG4J_DELEGATION_LOOP_URL + "
>>> for more details.";
>>>
>>>             Util.reportFailure(part1);
>>>             Util.reportFailure(part2);
>>>             throw new IllegalStateException(part1 + part2);
>>>         }
>>>
>>>     }
>>> ...
>>>
>>> }
>>>
>>> Thanks,
>>> Tom
>>
>> _______________________________________________
>> slf4j-user mailing list
>> slf4j-user at qos.ch
>> http://qos.ch/mailman/listinfo/slf4j-user
>>
> _______________________________________________
> slf4j-user mailing list
> slf4j-user at qos.ch
> http://qos.ch/mailman/listinfo/slf4j-user
>


More information about the slf4j-user mailing list