commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ceki Gülcü <>
Subject Re: [logging][PROPOSAL] a solution to incompatibility between log4j versions
Date Wed, 19 May 2004 14:06:13 GMT

The patch did not make it to the list but it is available
in bugzilla.

At 03:53 PM 5/19/2004, you wrote:
>With some changes to log4j HEAD and the following patch to
>commons-logging, it is now possible to compile commons-logging with
>1.3alpha and run it with both 1.3 *and* 1.2.8. Unfortunately, I was
>unable to get a c-l version compiled with 1.2.8 to also run with 1.3. 
>Mostly because I am unable to grok the java.lang.VerifyError.
>      [java] No suitable Log constructor [Ljava.lang.Class;@f9f9d8 for 
> org.apache.commons.logging.impl.Log4JLogger
>      [java] java.lang.VerifyError: (class: 
> org/apache/commons/logging/impl/Log4JLogger, method: warn signature: 
> (Ljava/lang/Object;Ljava/lang/Throwable;)V) Incom
>patible argument to function
>      [java]     at java.lang.Class.getDeclaredConstructors0(Native Method)
>      [java]     at 
> java.lang.Class.privateGetDeclaredConstructors(
>      [java]     at java.lang.Class.getConstructor0(
>      [java]     at java.lang.Class.getConstructor(
>      [java]     at 
> org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(
>      [java]     at 
> org.apache.commons.logging.impl.LogFactoryImpl.newInstance(
>      [java]     at 
> org.apache.commons.logging.impl.LogFactoryImpl.getInstance(
>      [java]     at 
> org.apache.commons.logging.LogFactory.getLog(
>      [java]     at 
> org.apache.commons.logging.log4j.DefaultConfigTestCase.setUpLog(
>      [java]     at 
> org.apache.commons.logging.log4j.DefaultConfigTestCase.setUp(
>      [java]     at junit.framework.TestCase.runBare(
>      [java]     at junit.framework.TestResult$1.protect(
>      [java]     at 
> junit.framework.TestResult.runProtected(
>      [java]     at
>      [java]     at
>      [java]     at junit.framework.TestSuite.runTest(
>      [java]     at
>      [java]     at junit.textui.TestRunner.doRun(
>      [java]     at junit.textui.TestRunner.start(
>      [java]     at junit.textui.TestRunner.main(
>I would be interested if someone could explain the source of the error.
>Anyway, to get 1.3 compiled code to also run on 1.2.8, the trick is to
>detect if running on 1.2 and to cast a Level instance as a Priority.
>The detection is straightforward:
>  private static final boolean is12 = 
> Priority.class.isAssignableFrom(Level.class);
>In Log4jLogger class, the various method calls become:
>  public void debug(Object message) {
>    if(is12) {
>      getLogger().log(FQCN, (Priority) Level.DEBUG, message, null );
>    } else {
>      getLogger().log(FQCN, Level.DEBUG, message, null );
>    }
>  }
>Refer to the included patch file for exact details.
>Note also that the was modified to reflect
>the fact that the throwable is no longer available in ThrowableInfo.
>At 02:57 PM 5/19/2004, Mario Ivankovits wrote:
>>Shapira, Yoav wrote:
>>>It'd be easy to do conditional stuff, as Joran for example is completely
>>>new in log4j 1.3, with Ant's <available> tasks and related conditionals.
>>I am not sure, if the "conditional stuff" helps. If you end up not being 
>>binary-compatible, i think commons-logging needs two compile-steps.
>>One with log4j-1.2.8 in the classpath, and one with log4j-1.3 for the 
>>Log4J13Logger and then package them together in one jar.
>>If we would like to avoid this, we could also use reflection at all to 
>>call those log( methods, but this might result in an performance loss.
>>-- Mario
>Ceki Gülcü
>      For log4j documentation consider "The complete log4j manual"
>      ISBN: 2970036908
>To unsubscribe, e-mail:
>For additional commands, e-mail:

Ceki Gülcü

      For log4j documentation consider "The complete log4j manual"
      ISBN: 2970036908  

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message