Hello,

I planed to use Log4J for my applikation but I got a problem by logging the
whole stack of my own Exception.

For excample:
I wrote an exceptionclass extending exception. The construktor expacts a
parentexception as a parameter. And finally I overwrote the method
printStackTrace to get both the parentexception and my own exception in one
stacktrace.

Like this:

  public class WQException extends Exception
  {
    private Exception parent = null;

    public WQException(String s, Exception parent)
    {
      super(s);
      this.parent=parent;
    }

    public void printStackTrace()
    {
      super.printStackTrace(s);
      if ( parent != null )
      {
        s.println("nested Exception is:");
        parent.printStackTrace(s);
      }
    }
  }

So a stacktrace should look like this:

  info.jankus.webquicky.exception.WQException: Auf das Feld "vorname" kann
nicht zugegriffen werden!
       at info.jankus.webquicky.test.Test1.getTest(Test1.java:38)
       at info.jankus.webquicky.WQStart.main(WQStart.java:57)
  nested Exception is:
  java.lang.IllegalArgumentException: object is not an instance of
declaring class
       at info.jankus.webquicky.test.Test1.getTest(Test1.java:34)
       at info.jankus.webquicky.WQStart.main(WQStart.java:57)

But when I use Log4J for logging the Error - e.g.: log.error("Folgender
Fehler ist aufgetreten",e); - the result looks like this:

  [ ERROR ] info.jankus.webquicky:63 <2002-08-23 12:09:42,670>
  Folgender Fehler ist aufgetreten
  info.jankus.webquicky.exception.WQException: Auf das Feld "vorname" kann
nicht zugegriffen werden!
       at info.jankus.webquicky.test.Test1.getTest(Test1.java:38)
       at info.jankus.webquicky.WQStart.main(WQStart.java:57)

I'm very disapointed that log4j is not calling the specific
printStackTrace-method of my own exception and about the loss of
information.

Does anybody has an idea for a fix, workaround or is there something wrong
with my code...?

Thanks in advance

Sven



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to