简体   繁体   English

将自定义日志记录过滤器与LoggingFeature一起用于Jersey客户端。

[英]Using custom logging filter with LoggingFeature for Jersey Client.

I am using Jersey 2.22. 我正在使用Jersey 2.22。 I have registered a LoggingFeature that logs requests, responses, headers, payload, etc based on the verbosity that I set however I would like to implement my own custom logging filter that this feature will use. 我已经注册了一个LoggingFeature ,它根据我设置的详细程度来记录请求,响应,标头,有效负载等,但是我想实现自己的自定义日志记录过滤器,该功能将使用该过滤器。

Looking at the source of LoggingFeature , it doesn't appear this is possible. 查看LoggingFeature的来源,看来这是不可能的。 This seems very inflexible. 这似乎很不灵活。 With previous versions of Jersey, it was very simple to implement a LoggingFilter and register it on the client. 在以前的Jersey版本中,实现LoggingFilter并将其注册到客户端非常简单。

I'd really like to implement my own version of ClientLoggingFilter so I can write a neat line to my log. 我真的很想实现自己的ClientLoggingFilter版本,以便可以在日志中写整齐的行。

Any suggestions? 有什么建议么? The documentation is lacking IMO. 该文档缺少IMO。 https://jersey.github.io/documentation/latest/logging_chapter.html#d0e15744 https://jersey.github.io/documentation/latest/logging_chapter.html#d0e15744

The solution for me was to implement my own version of a LoggingFeature with a custom request/response container injected. 对我来说,解决方案是使用注入的自定义请求/响应容器来实现自己的LoggingFeature版本。 Within the container I did the exact logging that we required. 在容器内,我执行了我们所需的确切日志记录。

Seems like a step backwards not being able to implement a simple filter and apply it to the client for things like custom logging. 似乎倒退了一步,无法实现简单的过滤器,无法将其应用于客户端(例如自定义日志记录)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM