You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Stephan Michels <st...@apache.org> on 2002/08/14 17:34:32 UTC

Re: logging of exceptions was: cvs commit: SourceMultiAction.java

On Wed, 14 Aug 2002, Vadim Gritsenko wrote:

> stephan@apache.org wrote:
>
> >               } catch (SourceException se) {
> >  -                getLogger().warn("Exception occurs while storing the content", se);
> >  -                return null;
> >  +                getLogger().error("Exception occurs while storing the content", se);
> >  +                throw new ProcessingException("Exception occurs while storing the content", se);
> >
> Stephan,
>
> Word of advice, if I may. There are two goals in exception handling: one
> is to give relevant information about error to the user (and log file),
> and another is to keep duplication of this information close to 0.
>
> You improved firt, but second is worse now: exception will be logged
> twice (We agreed some time ago that exception will be logged on the
> top-most level). You may want to have some logging here, but I suggest
> to decrease severity level to debug(), and may be to prevent logging
> full stacktrace:
>
>  +          getLogger().debug("Exception occurs while storing the content: " + se);

Thank you for the hint. I used the following combination

For the admin, if he want to be informed (sometimes I need
the complete stacktrace):
if (getLogger().isDebugEnabled())
  getLogger().debug(<message>, exception);


And for the clients:
throw new ProcessingException(<message>, exception);

Do this agree with your conventions?


Stephan Michels.

Ps. sorry for the double post, vadim.


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org