Jetty HTTP日志记录 [英] Jetty HTTP logging

查看:360
本文介绍了Jetty HTTP日志记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让Jetty记录所有HTTP请求(以及正文)和响应。这是Jetty原生支持的吗?理想情况下,它会记录到我现有的log4j日志文件。

I would like to have Jetty log all HTTP requests (along with the body) and responses. Is this natively supported by Jetty? Ideally it would log to my existing log4j log file.

我正在运行Jetty 6.

I am running Jetty 6.

推荐答案

Jetty附带了一个可以登录NCSA格式的请求记录器。这种格式不包括你需要的请求体之类的东西,但是这种标准格式适合像webalizer之类的工具。

Jetty comes with a request logger that can log in NCSA format. That format doesn't include things like request body as you require, but that standard format will fit tools like webalizer and the like.

如果你需要记录更多,你可以使用logback请求日志实现或通过实现Jetty的RequestLog接口编写自己的记录器。

If you need to log more you can use the logback request log implementation or write your own logger by implementing Jetty's RequestLog interface.

除此之外我强烈建议升级到jetty7 / 8(相同的代码库,但是8提供了servlet 3.0功能)。或者直接转到jetty9。

Besides that I'd highly recommend to upgrade to jetty7/8 (same codebase, but 8 provides servlet 3.0 functionality). Or directly move to jetty9.

这是请求日志的jetty9文档:
http://www.eclipse.org/jetty/documentation/current/configuring-logging.html#configuring-jetty-request-logs

Here's the jetty9 documentation for request logs: http://www.eclipse.org/jetty/documentation/current/configuring-logging.html#configuring-jetty-request-logs

与jetty7 / 8相同:
http ://wiki.eclipse.org/Jetty/Tutorial/RequestLog

Same for jetty7/8: http://wiki.eclipse.org/Jetty/Tutorial/RequestLog

我把它作为练习让你找到jetty6文档或者更好,升级。 :)

I leave it as an exercise for you to find the jetty6 docs or better yet, upgrade. :)

好的,偶然发现了jetty6文档: http://docs.codehaus.org/display/JETTY/Logging+Requests

Ok, just found the jetty6 docs by accident: http://docs.codehaus.org/display/JETTY/Logging+Requests

这篇关于Jetty HTTP日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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