You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by "Rieser, Michael (SCI TW)" <Mi...@stercomm.com> on 2004/12/10 15:56:45 UTC

ObjectRenderers

Is it possible to override the default logging behavior of Exceptions/Throwables?

I've been able to get ObjectRenderers to work for the logging signatures like the following:
	logger.debug(new Exception("error message");

but those which take the throwable as an additional argument don't seem to obey the Renderer
	logger.debug("error message", new Exception("won't be rendered the way I want");

Any help would be appreciated.

Thanks,
Mike


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: ObjectRenderers

Posted by Ceki Gülcü <ce...@qos.ch>.
Mike,

ObjectRendering is not automatically applied to the second argument of
printing methods but only to the first one (the message). Would you
care to explain how you'd like exceptions to be displayed?

BTW, if you are using log4j 1.3 and PatternLayout, you can register a
pattern converter for exceptions. PatternLayout will delegate
displaying the exception to your converter and the containing appender
will honor your custom treatment of the exception.

At 03:56 PM 12/10/2004, Rieser, Michael (SCI TW) wrote:
>Is it possible to override the default logging behavior of 
>Exceptions/Throwables?
>
>I've been able to get ObjectRenderers to work for the logging signatures 
>like the following:
>         logger.debug(new Exception("error message");
>
>but those which take the throwable as an additional argument don't seem to 
>obey the Renderer
>         logger.debug("error message", new Exception("won't be rendered 
> the way I want");
>
>Any help would be appreciated.
>
>Thanks,
>Mike

-- 
Ceki Gülcü

  The complete log4j manual:  http://qos.ch/log4j/  



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org