The Complete Log4j Manual warns that on some platforms, getting the caller 
class data can be very slow.  The C, F, l, L, and M conversion characters use 
"caller class" information.  Thus, it cautions against using these conversion 
characters.  (I'm paraphrasing because a direct quote of the manual would 
violate the license agreement.)

If you only want class information, you could include the logger name (%c) 
which is typically the caller's class.  I think this is an inexpensive 
operation.  Another option is to place the method name in the call string for 
areas that require method information and skip the M conversion character.

For more specifics, you can research when LocationInfo is generated for any one 
event.  You can look at the source for the PatternLayout, 
ClassNamePatternConverter, MethodLocationPatternConverter, LocationInfo, and 
LocationInfoFilter classes.

Also, if you look through Ceki's e-mails, at the end, they all have the same 
signature file that includes a reference to The Complete Log4j Manual.  So, 
while at first I got a similar impression to that of Aaron, I don't believe 
Ceki's reply in this case was simply a ploy to direct users to purchase the 
manual.

--Mark

-----Original Message-----
From: Korver, Aaron [mailto:[EMAIL PROTECTED]
Sent: Monday, February 07, 2005 9:11 AM
To: 'Log4J Users List'
Subject: RE: is log4j printing out class/method name expensive?


Ceki,
While I understand you are trying to make money, if you can't even have the
courtesy to answer a simple question, then why even respond?

Anil,
Log4j CAN print the class and method names, however, this is determined by
how you setup your log4j output.  It is my understanding that these would
only be created and parsed if your logger instance needs to print it out as
configured by your log4j.properties(.xml) file.  Perhaps someone not
interested in making money could clarify this for both of us.

> -----Original Message-----
> From: Ceki G�lc� [mailto:[EMAIL PROTECTED]
> Sent: Monday, February 07, 2005 11:08 AM
> To: Log4J Users List
> Subject: Re: is log4j printing out class/method name expensive?
> 
> 
> Anil,
> 
> The statement is only partial and hence incorrect.
> 
> At 05:47 PM 2/7/2005, you wrote:
> >"Log4j can print both class & method name, but in an 
> expensive way. It
> >creates a Throwable object, dumps the stack to a String, and 
> then parses the
> >string to get the class/method name. As some of our 
> applications requires
> >high throughput, we need to try to avoid unnecessary CPU cycles."
> >
> >Hello,
> >Someone made this statement and I wondered if it is true.
> >If I write logger.info("hello"); does it do this each time?
> >Thanks,
> >Anil Philip
> 
> -- 
> Ceki G�lc�
> 
>    The complete log4j manual: http://www.qos.ch/log4j/
> 
> 
> 
> ---------------------------------------------------------------------
> 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]

Reply via email to