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());
这篇关于如何在服务器上获取球衣日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在服务器上获取球衣日志?
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01