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 v yang <vp...@hotmail.com> on 2016/05/03 18:29:07 UTC

uncaught exception with log4j2

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


Re: uncaught exception with log4j2

Posted by v yang <vp...@hotmail.com>.
Thanks for all the replies.  I'll probably take a look into the wildfly log config to see if it will handle it.  Really wanted to use log4j2 to do that though.

vpyang

________________________________________
From: Matt Sicker <bo...@gmail.com>
Sent: Tuesday, May 3, 2016 7:26 PM
To: Log4J Users List
Subject: Re: uncaught exception with log4j2

If you can't catch the exception, then you'll just have to configure
Wildfly's logging separately:

https://docs.jboss.org/author/display/WFLY9/Logging+Configuration

On 3 May 2016 at 14:14, Paul Benedict <pb...@apache.org> wrote:

> Write yourself a Servlet Filter [1] that catches any exception, logs it,
> and passes it on. Your logger should be configured to write to a file. If
> the filter is the first in the chain, the exception caught is definitely
> unhanded.
>
> PS: If you don't pass on the exception, you have handled it (by
> definition). The container will think everything is fine if you don't.
>
> [1] https://docs.oracle.com/javaee/6/api/javax/servlet/Filter.html
>
> Cheers,
> Paul
>
> On Tue, May 3, 2016 at 2:04 PM, v yang <vp...@hotmail.com> wrote:
>
> > Is there no alternative to this? I really do not want to add a catch to
> > anything at all.
> >
> > vpyang
> >
> > ________________________________________
> > From: Ralph Goers <ra...@dslextreme.com>
> > Sent: Tuesday, May 3, 2016 11:54 AM
> > To: Log4J Users List
> > Subject: Re: uncaught exception with log4j2
> >
> > 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 <vp...@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
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> > For additional commands, e-mail: log4j-user-help@logging.apache.org
> >
> >
>



--
Matt Sicker <bo...@gmail.com>

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


Re: uncaught exception with log4j2

Posted by Matt Sicker <bo...@gmail.com>.
If you can't catch the exception, then you'll just have to configure
Wildfly's logging separately:

https://docs.jboss.org/author/display/WFLY9/Logging+Configuration

On 3 May 2016 at 14:14, Paul Benedict <pb...@apache.org> wrote:

> Write yourself a Servlet Filter [1] that catches any exception, logs it,
> and passes it on. Your logger should be configured to write to a file. If
> the filter is the first in the chain, the exception caught is definitely
> unhanded.
>
> PS: If you don't pass on the exception, you have handled it (by
> definition). The container will think everything is fine if you don't.
>
> [1] https://docs.oracle.com/javaee/6/api/javax/servlet/Filter.html
>
> Cheers,
> Paul
>
> On Tue, May 3, 2016 at 2:04 PM, v yang <vp...@hotmail.com> wrote:
>
> > Is there no alternative to this? I really do not want to add a catch to
> > anything at all.
> >
> > vpyang
> >
> > ________________________________________
> > From: Ralph Goers <ra...@dslextreme.com>
> > Sent: Tuesday, May 3, 2016 11:54 AM
> > To: Log4J Users List
> > Subject: Re: uncaught exception with log4j2
> >
> > 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 <vp...@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
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> > For additional commands, e-mail: log4j-user-help@logging.apache.org
> >
> >
>



-- 
Matt Sicker <bo...@gmail.com>

Re: uncaught exception with log4j2

Posted by Paul Benedict <pb...@apache.org>.
Write yourself a Servlet Filter [1] that catches any exception, logs it,
and passes it on. Your logger should be configured to write to a file. If
the filter is the first in the chain, the exception caught is definitely
unhanded.

PS: If you don't pass on the exception, you have handled it (by
definition). The container will think everything is fine if you don't.

[1] https://docs.oracle.com/javaee/6/api/javax/servlet/Filter.html

Cheers,
Paul

On Tue, May 3, 2016 at 2:04 PM, v yang <vp...@hotmail.com> wrote:

> Is there no alternative to this? I really do not want to add a catch to
> anything at all.
>
> vpyang
>
> ________________________________________
> From: Ralph Goers <ra...@dslextreme.com>
> Sent: Tuesday, May 3, 2016 11:54 AM
> To: Log4J Users List
> Subject: Re: uncaught exception with log4j2
>
> 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 <vp...@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
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

Re: uncaught exception with log4j2

Posted by v yang <vp...@hotmail.com>.
Is there no alternative to this? I really do not want to add a catch to anything at all.

vpyang

________________________________________
From: Ralph Goers <ra...@dslextreme.com>
Sent: Tuesday, May 3, 2016 11:54 AM
To: Log4J Users List
Subject: Re: uncaught exception with log4j2

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 <vp...@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


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


Re: uncaught exception with log4j2

Posted by Ralph Goers <ra...@dslextreme.com>.
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 <vp...@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