On Friday 23 Nov 2012 21:43:35 Robert Hailey wrote:
> 
> On 2012/11/23 (Nov), at 3:09 PM, Matthew Toseland wrote:
> 
> > The reason for this is generating the strings (and GCing them) can use a 
> > lot of CPU: it's vital that if logging is turned off for that class then it 
> > not do *anything*. [...] I'd be interested to know if any of the standard 
> > logging solutions have an answer for this...
> 
> slf4j includes a special marker where it injects logging arguments, so that:
> (1) Object.toString() is not called unless the log line is actually being 
> appended, and
> (2) The string building (as you mentioned) is not performed unless the log 
> line is actually appended.
> 
> The usage is similar to log4j, like this:
> 
> log.info("received '{}' from {}", packet, peer);
> 
> The cost/benefit trade off is approximately one function call versus cleaner 
> code; since it's a facade, you're not pinned to one log facility, and I know 
> for a fact that log4j (which is compatible with slf4j) has per-class log 
> levels (which you also mentioned).

What is the cost of mangling the bytecode? Only at startup (or even at compile 
time?) and when you change the logging settings?

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Devl mailing list
[email protected]
https://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl

Reply via email to