logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <ralph.go...@dslextreme.com>
Subject Re: uncaught exception with log4j2
Date Tue, 03 May 2016 16:54:13 GMT
All you need is to catch the exceptions by doing:

try {
} catch (Exception ex) {
	logger.error(“Uncaught exception:”, ex);
}

You would put this in your servlet, Controller or whatever the first thing in your application
is that gets control from Tomcat.

If you want to treat them specially then add a Marker to the error method.

Ralph


> On May 3, 2016, at 9:29 AM, v yang <vpyang@hotmail.com> wrote:
> 
> Hello list,
> 
> 
> I'm looking for a way to log any uncaught exceptions to a file.  I'm currently running
Wildfly 9.0.2 server and all uncaught exceptions are printing to console.  I'd like to use
log4j2 log those exceptions. Can anyone point me in the right direction.
> 
> 
> vpyang
> 



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


Mime
View raw message