You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Scruffles - <ba...@yahoo.com> on 2001/02/22 19:10:00 UTC

method names - how slow?

Of course I understand that reflection is slow.  My
boss is insistent that we should be able to log the
method name, however, and I'm not sure what to tell
him.  In our old logging system, the programmer passed
the method name as one of the parameters.  This is a
bit of a pain (not to mention it was prone to error). 
No one here wants to use anything with reflection
(personally, I don't think we even need the method
names).

I would like to just use Log4J's ability to show
method names, should the case arise that we really
need them - they could always be turned off.  

What is the general opinion?  Should reflection be
avoided at all costs, or should we just be careful of
what we log?

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices! http://auctions.yahoo.com/

Re: method names - how slow?

Posted by Ceki Gülcü <cg...@qos.ch>.
At 11:43 22.02.2001 -0800, Scruffles - wrote:
>Wow!  I just got done going through the source code. 
>I wouldn't have never thought of that.  I guess when
>they said it would be slow, I just assumed reflection.
> It never even occured to me that there isn't really a
>way to get that kind of information from reflection.  
>
>Does anyone know if Sun's JSR47 will allow a better
>way of getting this information (maybe from the VM)?
>
>I assume any solution created by Sun would quickly be
>integrated into Log4J

I think it's the other way around: any solution created by log4j will eventually be integrated into java.util.logging. :-) 

The keyword here is "eventually". The people at Sun are doing a very effective job at copying other peoples ideas. I call it Sun's "copy and conquer" model. They have done it with JCE, the Java Collection API and who knows what else. I expect people developing Java infrastructure to eventually realize that the JCP is just a fig leaf but I am not holding my breath. 

Coming back to the issue, Luc is right. My tests show that logging method, line or file information (localization) is about 40 to 50 times slower than logging without localization. Fortunately, localization can be very easily turned on or off. Cheers, Ceki

>--- Luke Blanshard <lu...@quiq.com> wrote:
>> I don't believe reflection has anything to do with
>> it.  My understanding is that it
>> generates a stack trace, and figures out the method
>> name from that.  This means that
>> every (executed) log statement causes the creation
>> of an exception (which is how stack
>> traces are generated).  I imagine that this would
>> slow things down somewhat, or maybe a
>> lot, but I haven't actually tried it.
>
>__________________________________________________
>Do You Yahoo!?
>Yahoo! Auctions - Buy the things you want at great prices! http://auctions.yahoo.com/
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-user-help@jakarta.apache.org

----
Ceki Gülcü          Web:   http://qos.ch      
av. de Rumine 5     email: cgu@qos.ch (preferred)
CH-1005 Lausanne           ceki_gulcu@yahoo.com
Switzerland         Tel: ++41 21 351 23 15


Re: method names - how slow?

Posted by Scruffles - <ba...@yahoo.com>.
Wow!  I just got done going through the source code. 
I wouldn't have never thought of that.  I guess when
they said it would be slow, I just assumed reflection.
 It never even occured to me that there isn't really a
way to get that kind of information from reflection.  

Does anyone know if Sun's JSR47 will allow a better
way of getting this information (maybe from the VM)?

I assume any solution created by Sun would quickly be
integrated into Log4J

--- Luke Blanshard <lu...@quiq.com> wrote:
> I don't believe reflection has anything to do with
> it.  My understanding is that it
> generates a stack trace, and figures out the method
> name from that.  This means that
> every (executed) log statement causes the creation
> of an exception (which is how stack
> traces are generated).  I imagine that this would
> slow things down somewhat, or maybe a
> lot, but I haven't actually tried it.

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices! http://auctions.yahoo.com/

Re: method names - how slow?

Posted by Luke Blanshard <lu...@quiq.com>.
I don't believe reflection has anything to do with it.  My understanding is that it
generates a stack trace, and figures out the method name from that.  This means that
every (executed) log statement causes the creation of an exception (which is how stack
traces are generated).  I imagine that this would slow things down somewhat, or maybe a
lot, but I haven't actually tried it.

Luke

Scruffles - wrote:

> Of course I understand that reflection is slow.  My
> boss is insistent that we should be able to log the
> method name, however, and I'm not sure what to tell
> him.  In our old logging system, the programmer passed
> the method name as one of the parameters.  This is a
> bit of a pain (not to mention it was prone to error).
> No one here wants to use anything with reflection
> (personally, I don't think we even need the method
> names).
>
> I would like to just use Log4J's ability to show
> method names, should the case arise that we really
> need them - they could always be turned off.
>
> What is the general opinion?  Should reflection be
> avoided at all costs, or should we just be careful of
> what we log?
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Auctions - Buy the things you want at great prices! http://auctions.yahoo.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Re: method names - how slow?

Posted by Eduardo Issao Ito <it...@integrationtech.com.br>.
I have a server that generates a lot of log messages, and runs in about 
15 seconds. Printing the class name, method name and line number, it 
took 5 minutes...

Scruffles - wrote:

> Of course I understand that reflection is slow.  My
> boss is insistent that we should be able to log the
> method name, however, and I'm not sure what to tell
> him.  In our old logging system, the programmer passed
> the method name as one of the parameters.  This is a
> bit of a pain (not to mention it was prone to error). 
> No one here wants to use anything with reflection
> (personally, I don't think we even need the method
> names).
> 
> I would like to just use Log4J's ability to show
> method names, should the case arise that we really
> need them - they could always be turned off.  
> 
> What is the general opinion?  Should reflection be
> avoided at all costs, or should we just be careful of
> what we log?
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Auctions - Buy the things you want at great prices! http://auctions.yahoo.com/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org


-- 
Eduardo Issao Ito <it...@integrationtech.com.br>
Integration Technologies Ltda. <http://www.integrationtech.com.br>
Rua Marina Saddi Haidar, 176
04650-050 / Sao Paulo / SP / Brasil
Phone: +55 11 5522-4848 x311
Fax:   +55 11 5524-1125