我们在这里运行 RESTEasy 2.3.0.GA,我正在努力解决https://stackoverflow.com/questions/18219237/jax-rs-path-regex-fails-for-just-one-of-an- or-expression,我不知道如何让 RESTEasy 坦白为什么它认为特定的 URI 没有映射到我的处理程序。是否有一些调试级别可以让 RESTEasy 显示它的调度?
问问题
4813 次
2 回答
3
文档对您将获得的内容含糊不清,但他们使用的是 log4j、logback 和 java.util.logging 的 Logger。就我而言,将以下内容添加到 logback.xml 会给我一些稀疏信息。
<logger name="org.jboss.resteasy.core" level="debug" />
<logger name="org.jboss.resteasy.specimpl" level="debug" />
<logger name="org.jboss.resteasy.plugins.server" level="debug" />
于 2013-08-14T17:17:08.483 回答
0
这对我有用:
@Provider
@ServerInterceptor
public class LoggingInterceptor implements ContainerRequestFilter {
private static final ObjectMapper MAPPER = new ObjectMapper();
@Override
public void filter(ContainerRequestContext containerRequestContext) throws IOException {
if (REQUESTS_LOGGER.isDebugEnabled()) {
final String method = containerRequestContext.getMethod();
final String url = containerRequestContext.getUriInfo().getRequestUri().toString();
final StringBuilder headersStr = new StringBuilder();
MultivaluedMap<String, String> headers = containerRequestContext.getHeaders();
for (MultivaluedMap.Entry<String, List<String>> header : headers.entrySet()) {
headersStr.append(header.getKey()).append(": ").append(header.getValue()).append('\n');
}
String json = null;
if ("POST".equals(method) || "PUT".equals(method)) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
IOUtils.copy(containerRequestContext.getEntityStream(), baos);
byte[] jsonBytes = baos.toByteArray();
json = new String(jsonBytes, "UTF-8");
Object jsonObject = MAPPER.readValue(json, Object.class);
json = MAPPER.writeValueAsString(jsonObject);
containerRequestContext.setEntityStream(new ByteArrayInputStream(jsonBytes));
}
REQUESTS_LOGGER.restCall(method, url, headersStr.toString(), json == null ? "empty" : json);
}
}
}
于 2015-08-01T08:23:06.020 回答