John,

Thanks for the pointer. Neat idea. One comment though: the approach is intrusive in 
the sense that instantiation for objects to be traced at the method level must be 
performed by a factory class (or method) not by a constructor. This is a 
non-negligible restriction.. Can it be circumvented? Thanks again, Ceki    

At 09:34 22.03.2001 -0500, you wrote:
>Alex,
>
>I don't beleive that there is anything like this built into Log4j.  You can
>fairly easily do it yourself though.  Rather than describe it here I'll just
>point to in the right direction.
>
>Take a look at the Proxy & InvokationHandler classes.  NOTE: This is only
>available with JDK 1.3 I believe.  If you've followed a factory pattern this
>is easy to implement.  If not (if you just go and "new FooBarClass()"
>directly you'll have more work to do.
>
>Hmm, there was an article that described this, wait a minute...  Okay: the
>article's name is "Friction Free Debuging with Proxies" it at:
>http://www.java-pro.com/upload/free/features/javapro/2000/11nov00/jm0011/jm0
>011.asp
>
>It doen't use Log4j, but it's easy enough to alter.  Take your time and read
>it, it's not too difficult to follow.  There are some caveats to using it
>('this' pointer related)  but nothing dreadful. (Except performance!)
>
>
>Hope this helps
>
>John Volkar
>Senior Software Engineer II
>E-Transport, a division of Descartes (DSGX)
>[EMAIL PROTECTED]
>
>
>-----Original Message-----
>From: Alex Colic [mailto:[EMAIL PROTECTED]]
>Sent: Thursday, March 22, 2001 9:18 AM
>To: [EMAIL PROTECTED]
>Subject: wrapper for Log4j for method entrance/exit?
>
>
>Hi,
>
>I am adding more debugging to my app. As my program runs I would like to
>print to a file as it enters methods and exits them. I know that at the
>beginning of the method and at the end I could do something like
>
>log("Entered method: MyMethod()");
>
>but that would be tedious.
>
>Is there some time of wrapper class that I could pass the class to in a
>constructor that as methods in the class are called, logging occurs?
>
>Thanks for any help.
>
>Alex
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]


I hope to see you at my ApacheCon 2001 presentation 
entitled "Log4j, A Logging Package for Java".

See http://ApacheCon.Com/2001/US/ for more details.

----
Ceki Gülcü          Web:   http://qos.ch     
av. de Rumine 5     email: [EMAIL PROTECTED] (preferred)
CH-1005 Lausanne           [EMAIL PROTECTED]
Switzerland         Tel: ++41 21 351 23 15


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

Reply via email to