logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ceki Gülcü <...@urbanet.ch>
Subject Re: Problem with LocationInfo class
Date Wed, 31 Jan 2001 23:58:30 GMT

Paul,

I think we are in luck as there seems to be an easy an general solution. It is demonstrated
by four classes A, B, C, D and a test class T.

--------------------------------------- A.java
public class  A {

  static String FCQN = "A";

  public
  void foo() {
    System.err.println("In A.foo()");
    inner(FCQN);
  }

  public
  void inner(String fqcnGuess) {
    System.err.println("In A.inner()");    
    Exception e = new Exception();
    e.printStackTrace();
    System.err.println("guess:"+fqcnGuess);    
  }

}

---------------------------------------- B.java
public class B extends A {

  static String FCQN = "B";

  public
  void foo() {
    System.err.println("In B.foo()");
    inner(FCQN);
  }
}

------------------------------------------ C.java
public class C extends A {

  static String FCQN = "C";

  public
  void inner(String fqcnGuess) {
    System.err.println("In C.inner()");
    Exception e = new Exception();
    e.printStackTrace();
    System.err.println("guess:"+fqcnGuess);    
  }

}

------------------------------- D.java 
public class  D extends A {

  static String FCQN = "D";


  public
  void foo() {
    System.err.println("In D.foo()");
    inner(FCQN);
  }

  public
  void inner(String fqcnGuess) {
    System.err.println("In D.inner()");    
    Exception e = new Exception();
    e.printStackTrace();
    System.err.println("guess:"+fqcnGuess);    
  }

}

---------------------------------- T.java 

public class T {
  public static void main(String[] args) {

    A a = new A();
    A b = new B();
    A c = new C();
    A d = new D();

    System.err.println("---------------------------");
    a.foo();

    System.err.println("---------------------------");
    b.foo();

    System.err.println("---------------------------");
    c.foo();

    System.err.println("---------------------------");
    d.foo();

    System.err.println("---------------------------");
    new A().foo();

    System.err.println("---------------------------");
    new B().foo();

    System.err.println("---------------------------");
    new C().foo();

    System.err.println("---------------------------");
    new D().foo();
  }
}

If you actually run this, you will notice that the guess is always correct. I'll move the
code to this simpler and more solid implementation, unless you want to do it, Paul.. Cheers,
Ceki  

At 15:02 31.01.2001 -0800, you wrote:
>I'm experiencing the problem with a modified version of the 1.0.4 code.  I
>haven't been able to build the CVS version on WinNT, where I'm having the
>problem, but I didn't see anything in the CVS source that would change this
>behavior.
>
>We discussed earlier how supplying the FQN to the Category would fix "the
>problem."  But back then, "the problem" had to do with the case where
>l7dlog was overridden by the Category subclass.  When the Category.l7dlog
>was changed to call forcedLog, making the override unnecessary, the stack
>trace changed.  The subcategory is no longer the last entry before the
>caller.  Rather, the category log method is.  At my customer site, I've
>fixed this locally by changing the subcategory constructor to NOT alter the
>instanceFQN (which is only possible with the 1.0.4 version since the needed
>constructor is not available in the present CVS version).
>
>Does this seem correct?  I won't be able to verify the current CVS behavior
>for sure until I either get home to build it on Linux or learn Ant for NT
>(which I'm working on).
>
>- Paul
>
>Paul Glezen
>IT Specialist
>WebSphere Engagement Team
>Tel: 818 539 3321
>pglezen@us.ibm.com
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-dev-help@jakarta.apache.org

----
Ceki Gülcü - Independent IT Consultant                                        

av. de Rumine 5            Tel: ++41 21 351 23 15   
CH-1005 Lausanne        e-mail: cgu@urbanet.ch  or
Switzerland                     ceki_gulcu@yahoo.com


Mime
View raw message