Return-Path: Delivered-To: apmail-struts-dev-archive@www.apache.org Received: (qmail 91854 invoked from network); 22 Aug 2006 22:24:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 22 Aug 2006 22:24:32 -0000 Received: (qmail 43961 invoked by uid 500); 22 Aug 2006 22:24:29 -0000 Delivered-To: apmail-struts-dev-archive@struts.apache.org Received: (qmail 43923 invoked by uid 500); 22 Aug 2006 22:24:29 -0000 Mailing-List: contact dev-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Developers List" Reply-To: "Struts Developers List" Delivered-To: mailing list dev@struts.apache.org Received: (qmail 43912 invoked by uid 99); 22 Aug 2006 22:24:29 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Aug 2006 15:24:29 -0700 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=DNS_FROM_RFC_ABUSE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of nbubna@gmail.com designates 66.249.82.239 as permitted sender) Received: from [66.249.82.239] (HELO wx-out-0506.google.com) (66.249.82.239) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Aug 2006 15:24:28 -0700 Received: by wx-out-0506.google.com with SMTP id i31so2195494wxd for ; Tue, 22 Aug 2006 15:24:07 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=O5x2tQN0/hO5bbU/znklrsNcfT3es22dZO1W9KfPy3PCNoeQg/uE+HMtAnzOUN0Ayk9Fx/qCh3T8Dx6UOlYUVzpC8+DZT3k89mkzVRVHsTXhW9oVpdDns3tgFaIpXDINyCsz3pEYaeYAvzyYk2Z6a0Q3zTCAr4FVZWl8HFk8Hno= Received: by 10.90.105.19 with SMTP id d19mr686543agc; Tue, 22 Aug 2006 15:24:07 -0700 (PDT) Received: by 10.90.94.9 with HTTP; Tue, 22 Aug 2006 15:24:07 -0700 (PDT) Message-ID: <4d651da50608221524m18910633u8f76a8883b106c84@mail.gmail.com> Date: Tue, 22 Aug 2006 15:24:07 -0700 From: "Nathan Bubna" To: "Struts Developers List" Subject: Re: Whose log is this anyway? (was Re: [s1] Commons-Lang) In-Reply-To: <16d6c6200608221426g4984b1a3l11e0bd047119ee2f@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <8b3ce3790608220401u12a0aa96h542607da8df15917@mail.gmail.com> <44EB2F2E.2010303@twdata.org> <44EB332A.70804@twdata.org> <44EB6747.5060905@twdata.org> <16d6c6200608221411k2caaabc7pfaf8f655aca3c51e@mail.gmail.com> <53F176DB-3432-4DD5-AFCB-25E599DBC867@tfenne.com> <16d6c6200608221426g4984b1a3l11e0bd047119ee2f@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N On 8/22/06, Martin Cooper wrote: > On 8/22/06, Tim Fennell wrote: > > > > On Aug 22, 2006, at 5:11 PM, Martin Cooper wrote: > > > > > if (isDebugLoggingEnabled()) { > > > log.debug("And the answer is: " + expensiveMethodCallHere()); > > > } > > > > > > I don't know about you, but I'm very thankful for that guard when > > > debug > > > logging is disabled (e.g. in production). Without it, I'm going to > > > make that > > > expensive method call even if logging is disabled - and then just > > > throw away > > > the result after doing nothing in log.debug. Even a lowly toString > > > () call, > > > frequently used in debug logging, can get expensive, so it's not > > > like this > > > is a corner case. > > > > > > -1 on getting rid of guards. > > > > I agree that in rare cases you might want to be able to do this > > still. But in the vastly more common 2nd case you cite (the > > expensive toString() call), that's entirely the point of this. Log > > methods take Object.../Object[] and only toString the objects in the > > array if the appropriate log level is enabled. > > > No, I don't think you're getting what I'm saying. I'm not talking about > internal toString() calls, I'm talking about something like: > > log.debug("And the answer is: " + myBigObject.toString()); > > That toString() method is going to be invoked before the log.debug method is > ever called, so the cost is sunk even if debug logging is disabled. > > Now, I get the point that I should probably have used a parameterised string > and passed in myBigObject, letting the log method to the toString() call, > but people are so used to doing things like the above that it will still > happen. True. Also true is that the same people are also used to wrapping such calls in isDebugEnabled() which i don't think anyone wants to abolish. They just want a shorthand to be available. Besides, we are still talking about the internal logging facility for Struts2 (and potentially directly tied derivate libraries), not something application developers are supposed to be using, right? --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org For additional commands, e-mail: dev-help@struts.apache.org