How to get jersey logs at server?(如何在服务器上获取球衣日志?)
问题描述
我将球衣用于 REST WS.如何在服务器端启用球衣日志?
I am using jersey for a REST WS. How do I enable jersey logs at server side?
长篇大论:我得到一个客户端异常 - 但我在 tomcat 日志中看不到任何内容[它甚至没有达到我的方法].由于堆栈跟踪说toReturnValue"它确实从服务器得到了一些东西.但我不知道服务器说了什么.
Long story: I get a clientside exception - but I don't see anything in tomcat logs [It doesn't even reach my method]. Since the stack trace is saying "toReturnValue" it did get something from server. But I don't know what the server said.
Exception in thread "main" java.lang.IllegalArgumentException: source parameter must not be null
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:98)
at com.sun.xml.internal.ws.message.AbstractMessageImpl.readPayloadAsJAXB(AbstractMessageImpl.java:100)
**at com.sun.xml.internal.ws.client.dispatch.JAXBDispatch.toReturnValue(JAXBDispatch.java:74)**
at com.sun.xml.internal.ws.client.dispatch.DispatchImpl.doInvoke(DispatchImpl.java:191)
at com.sun.xml.internal.ws.client.dispatch.DispatchImpl.invoke(DispatchImpl.java:195)
推荐答案
如果要在服务端开启日志,需要注册LoggingFilter Jersey 过滤器(在容器端).
If you want to turn on logging on the server side, you need to register the LoggingFilter Jersey filter (on the container side).
此过滤器将记录请求/响应标头和实体.
这是您需要添加到 ResourceConfig 类的内容:
Here's what you need to add to your ResourceConfig class:
@ApplicationPath("/")
public class MyApplication extends ResourceConfig {
public MyApplication() {
// Resources.
packages(MyResource.class.getPackage().getName());
register(LoggingFilter.class);
}
}
请注意,相同的过滤器也适用于客户端.
Note that the same filter also works on the client side.
Client client = Client.create();
client.addFilter(new LoggingFilter());
这篇关于如何在服务器上获取球衣日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在服务器上获取球衣日志?
基础教程推荐
- 修改 void 函数的输入参数,然后读取 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- Struts2 URL 无法访问 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
