在我当前安装的 Spring CXF JAX-RS Servlet 中,异常被记录到 log4j DEBUG 通道:
DEBUG http-8134-2 org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper - WebApplicationException has been caught, status: 500, message: Unrecognized field "links" (Class Result), not marked as ignorable
at [Source: {"links"}; line: 1, column: 11] (through reference chain: bbc.news.naf.elections.data.model.client.Result["links"])
javax.ws.rs.WebApplicationException: org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "links" (Class Result), not marked as ignorable
at [Source: {"links":[{}; line: 1, column: 11] (through reference chain: bbc.news.naf.elections.data.model.client.Result["links"])
at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:243)
at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:89)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:211)
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213)
显然,这并不理想。如何让 CXF 将这些异常堆栈跟踪记录到更相关的内容,如 WARN 或 ERROR?