如何使用log4j查看Jersey [英] How to use log4j to see into Jersey

查看:222
本文介绍了如何使用log4j查看Jersey的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是log4j的新手,我正在尝试使用它来更好地理解为什么我的资源提供 415媒体类型不支持标题。

I'm new to log4j and am trying to use it to better understand why my resource is providing a 415 Media Type Not Supported header.

我正在使用以下内容:

log4j.rootCategory=WARN, stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c:%L - %m%n

log4j.category.com.sun.jersey=DEBUG,stdout

这个似乎就像它应该可以工作但我在控制台中没有显示有关POST到达此应用程序的任何内容。我知道它正在到达应用程序,因为如果我关闭应用程序,POSTer会在尝试POST时抛出连接被拒绝。

This seems like it should work but I'm showing nothing in the console about the POST reaching this application. I know it is reaching the application because if I turn the application off, the POSTer throws a "connection refused" when trying to POST.

推荐答案

我无法登录工作,但我能够确定如何获取我需要的ContentType。我不得不把它添加到我的班级......

I couldn't get logging to work, but I was able to determine how to get the ContentType which is what I needed. I had to add this to my class...

@Context
UriInfo uriInfo;

@PostConstruct
public void myfunc() {
    if (uriInfo == null) { //breakpoint on this line, so I can see what uriInfo is

    }
}

这篇关于如何使用log4j查看Jersey的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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