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());
这篇关于如何在服务器上获取球衣日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在服务器上获取球衣日志?


基础教程推荐
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 降序排序:Java Map 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01