Disable logging of Exception in Bean

2019-09-15 11:28发布

问题:

I'm using Wildfly 10 and JAX-RS (resteasy) and have a Bean being injected in another Bean:

@Path("foo")
public class FooResource {
    @Inject
    BarBean bar;
    ...
}

Then I'm calling a method on bar that throws a RuntimeException. I'm handling this Exception in FooResource, but Wildfly has interceptors that print the stack trace to the log. I don't want this to happen. Is there any way to disable this behavior?

回答1:

I could only reproduce this when the @Injected bean was a EJB (with Wildfly-9).

You can disable EJB exception logging through the webinterface (:9990)

Configuration -> Subsystems -> EJB 3 -> Log system exceptions Put this value to false and you should not see exceptions logged anymore.