开发者

JSF 2 - How to log Ajax request failures on server

I'm trying to find a graceful way of logging 开发者_运维百科unhandled exceptions that occur in my JSF application when an Ajax-based request fails. Right now I don't always see any visual indication or output in the server logs when some Ajax requests fail due to an exception.

I would like to avoid cluttering my managed beans with code like this in every getter, setter, action method, etc that might be called from an Ajax request:

public SomeWidget getSomeWidget() {
    try {
        return methodThatGetsWidget();
    } catch (RuntimeException e) {
        logger.error("Exception occurred", e);
        throw e;
    }
}

Is there some hook in the JSF framework to catch exceptions that originate during Ajax requests so I have a central place to put the logging code?

EDIT:

I'm currently using the slf4j 1.6.1 interfaces in my code with log4j 1.2.16 as the actual logging implementation. My JSF implementation is Mojarra 2.1.1 and the container is Tomcat 7.0.14. I'm also using PrimeFaces 3.0.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜