如何在服务器上获取球衣日志? [英] How to get jersey logs at server?

查看:21
本文介绍了如何在服务器上获取球衣日志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将球衣用于 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());

这篇关于如何在服务器上获取球衣日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆