struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathan Bubna" <nbu...@gmail.com>
Subject Re: Whose log is this anyway? (was Re: [s1] Commons-Lang)
Date Tue, 22 Aug 2006 22:24:07 GMT
On 8/22/06, Martin Cooper <martinc@apache.org> wrote:
> On 8/22/06, Tim Fennell <tfenne@tfenne.com> 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


Mime
View raw message