I knew about the location info stuff, but this applies to all messages
logged, and that will clearly affect performance even more than doing it
for just a few log messages.  Also, the location info does not include
the entire stack trace, thus making it difficult to trace the entire
chain of method calls...  The problem with my approach is that it is not
configurable; you have to recompile to add stack trace information to a
particular place in your code.  But I still think it is useful, for
debugging purposes mainly.

Ciao,
  Hein

On Tue, 2002-07-30 at 22:34, Mark Womack wrote:
> Logging events also support something called location info.  It records
> where the event was logged from and can be displayed via the PatternLayout
> (see the javadoc for details).  It displays the stack from where the logging
> event was recorded.  All you have to do is use the correct conversion
> character in the PatternLayout.
> 
> But it will affect performance if displayed with every logging message (as
> will your code below, I believe).
> 
> -Mark
> 
> > -----Original Message-----
> > From: Hein Meling [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, July 30, 2002 12:48 PM
> > To: Log4J Users List
> > Subject: feature request: logging a stack trace
> > 
> > 
> > hi.
> > 
> >   sorry if this is not the right place for this kind of request, but i
> > don't want to subscribe to the developers list.
> > 
> >   anyway, sometimes it may be very useful to log a stack 
> > trace, even if
> > there was no exception, in order to determine from where a method is
> > being called.  is this idea something that could be interesting to add
> > to the Logger (or Category) class in Log4j?  That is a method like:
> > logStackTrace(), or whatever...
> > 
> >   my implementation (residing in a class called Debug) is 
> > very rough so,
> > it needs a bit of cleaning up to fit well into log4j:
> > 
> > 
> >   public static void logStackTrace(org.apache.log4j.Logger log)
> >   {
> >     try {
> >       throw new Exception();
> >     } catch (Exception e) {
> >       StringWriter swriter = new StringWriter();
> >       e.printStackTrace(new PrintWriter(swriter));
> >       log.debug(swriter.toString());
> >     }
> >   }
> > 
> > 
> >   comments?
> > 
> > ciao,
> > - hein
> > 
> > --
> > To unsubscribe, e-mail:   
> > <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail: 
> > <mailto:[EMAIL PROTECTED]>
> > 
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


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

Reply via email to