Return-Path: Delivered-To: apmail-directory-dev-archive@www.apache.org Received: (qmail 79332 invoked from network); 5 Jun 2010 08:36:02 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 5 Jun 2010 08:36:02 -0000 Received: (qmail 61317 invoked by uid 500); 5 Jun 2010 08:36:02 -0000 Delivered-To: apmail-directory-dev-archive@directory.apache.org Received: (qmail 61290 invoked by uid 500); 5 Jun 2010 08:36:02 -0000 Mailing-List: contact dev-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Apache Directory Developers List" Delivered-To: mailing list dev@directory.apache.org Received: (qmail 61283 invoked by uid 99); 5 Jun 2010 08:36:02 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 05 Jun 2010 08:36:02 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of akarasulu@gmail.com designates 209.85.161.50 as permitted sender) Received: from [209.85.161.50] (HELO mail-fx0-f50.google.com) (209.85.161.50) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 05 Jun 2010 08:35:56 +0000 Received: by fxm1 with SMTP id 1so1563850fxm.37 for ; Sat, 05 Jun 2010 01:35:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:content-type; bh=GdfX78ckJ3BMXZdzgyhuu6TDy5HE7tY3fpdIfwBM5ng=; b=dcoM7IbKLKW01Atn1rUOgdx1yajeL3b0mG71sFoGE0aOFHUGw0xkD/ieAOBxRCoIlt EZMtARgSLFeQfAEaYMzy4uJR/s0Lw4pCNhdvFzHknGDt319wzAhFz6/CRXb2A6NE+LY+ j1S1LUfRsD1NpHUhN3IafhrGmWNVZqHFAkV4k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; b=Ccs9w0O4z52Fb4qr0gQfGB57Qm6pzpbbfP8J4r7EvZZ0BHqjDGHsT51RrzX4bQQErQ Ya6ATB41Mjq6q/1w/6MZNMODbKBRWoHA8rSQ3HKlkD0ND7D+m7NUCurkBF1vItPM3K3i LO3an+yI2ygh99ga+z/q7+FTZdzQpOC1bSPOQ= MIME-Version: 1.0 Received: by 10.239.182.2 with SMTP id o2mr891572hbg.51.1275726935806; Sat, 05 Jun 2010 01:35:35 -0700 (PDT) Sender: akarasulu@gmail.com Received: by 10.239.183.81 with HTTP; Sat, 5 Jun 2010 01:35:35 -0700 (PDT) In-Reply-To: <46E5C9A4-0F65-4D0A-9BB7-279EFD43B629@toolazydogs.com> References: <4C081B8B.1000700@otego.com> <46E5C9A4-0F65-4D0A-9BB7-279EFD43B629@toolazydogs.com> Date: Sat, 5 Jun 2010 11:35:35 +0300 X-Google-Sender-Auth: OhStc9fRnkN7adp6RlRVJmfzZsg Message-ID: Subject: Re: Exception Logging From: Alex Karasulu To: Apache Directory Developers List Content-Type: multipart/alternative; boundary=001485f1ec20d6d44c0488445267 X-Virus-Checked: Checked by ClamAV on apache.org --001485f1ec20d6d44c0488445267 Content-Type: text/plain; charset=ISO-8859-1 On Fri, Jun 4, 2010 at 3:55 PM, Alan D. Cabrera wro > > On Jun 3, 2010, at 2:15 PM, Felix Knecht wrote: > > > -----BEGIN PGP SIGNED MESSAGE----- > > Hash: SHA1 > > > > We have a lot of following constructs: > > > > log.error( I18n.err( I18n.ERR_04007 ) ); > > throw new DecoderException( I18n.err( I18n.ERR_04007 ) ); > > > > What about logging the exception within the exception itself like > > > > public DecoderException(String message) > > { > > super( message ); > > log.error( message ); > > } > > > > > > This will avoid having log.error all over the place and the translation > > must be done only once instead of twice like above. > > This is not a very good pattern for a number of reasons. > > First, you cannot control logging at the source of the error. Admittedly > this is an error message but I have run into times where I want to turn off > the klaxon to see what the real problem is. > > Second, constructors should not have side effects. It's never a good idea. > > Third, I never log an error if I am throwing an exception. It just adds > noise. I will, however, log additional useful information that is not in > the exception message. Just parroting what's in the exception is of little > value. > > +1 > Finally, what the heck is ERR_04007? :) I thought there already was a > discussion and community consensus about how there is little to negative > value in using numbers as error messages. Maybe I missed the conversation > where this opinion was reversed. If so, ignore this bit. :) > > +1 - we need to find a way to make this easier to read either with the IDE's help or other. -- Alex Karasulu My Blog :: http://www.jroller.com/akarasulu/ Apache Directory Server :: http://directory.apache.org Apache MINA :: http://mina.apache.org To set up a meeting with me: http://tungle.me/AlexKarasulu --001485f1ec20d6d44c0488445267 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Fri, Jun 4, 2010 at 3:55 PM, Alan D. Cabrera <list@toolazydogs.com> wro<= br>

On Jun 3, 2010, at 2:15 PM, Felix Knecht wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> We have a lot of following constructs:
>
> log.error( I18n.err( I18n.ERR_04007 ) );
> throw new DecoderException( I18n.err( I18n.ERR_04007 ) );
>
> What about logging the exception within the exception itself like
>
> public DecoderException(String message)
> {
> =A0 =A0super( message );
> =A0 =A0log.error( message );
> }
>
>
> This will avoid having log.error all over the place and the translatio= n
> must be done only once instead of twice like above.

This is not a very good pattern for a number of reasons.

First, you cannot control logging at the source of the error. =A0Admittedly= this is an error message but I have run into times where I want to turn of= f the klaxon to see what the real problem is.

Second, constructors should not have side effects. =A0It's never a good= idea.

Third, I never log an error if I am throwing an exception. =A0It just adds = noise. =A0I will, however, log additional useful information that is not in= the exception message. =A0Just parroting what's in the exception is of= little value.


+1
=A0
Finally, what the heck is ERR_04007? :) =A0I thought there already was a di= scussion and community consensus about how there is little to negative valu= e in using numbers as error messages. =A0Maybe I missed the conversation wh= ere this opinion was reversed. =A0If so, ignore this bit. =A0:)


+1 - we need to find a way to make thi= s easier to read either with the IDE's help or other.=A0
--
Alex Karasulu
My Blog :: http://www.jroller.com/akarasulu/
Apache Directory Server :: http://d= irectory.apache.org
Apache MINA :: http://mina.apache.org
To set up a meeting with me: http://tungle.me/AlexKarasulu
--001485f1ec20d6d44c0488445267--