Hi,
What you do, be consistent ;)  That'll make it easier to understand and
refactor later if necessary.  Other than that, it's a matter of style.
Sometimes it's a matter of personal style, sometimes organizational
guidelines.  There's an ISO standard somewhere about this, but I don't
remember off the top of my head.

>For example, do you log just before you do something:
>  logger.debug("connecting to the database");
>or after
>   logger.debug("connected to the database");
>or both?

Both, if it's a significant operation.  Also for DEBUG-level statements,
I always use logger.isDebugEnabled() around them for performance.  It
makes a big difference on large systems.

>Do you log when you throw an exception, catch one, or both?

Both, on the principal that exceptions are serious things and you want
to have caller (or thrower) as well as receiver (catcher) logging for
them.  There've been numerous times that I found having both logged
together gives me significant context information for the exception.

>Preachers of aspect oriented programming might not mind seeing a
logging
>statement at the entry and exit of every method. Some would certainly
find
>this to be overkill.

Overkill.  But then again I'm very performance oriented.

Like I said, it's a matter of style.  The above are just IMHO.

Yoav Shapira
Millennium ChemInformatics
This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to