记录 CXF 中解析的主机名
我有一个使用 CXF 的 java Web 服务客户端。服务器有 10 多个可能的 ip,通过动态 dns 解析。我已正确配置 jvm,不缓存 dns。
我的问题是,我需要使用有效负载传送到的 IP 登录客户端。仅记录主机名是行不通的,因为主机名到 IP 的解析不断变化。
I have a java web service client that uses CXF. The server has 10+ possible ips that are resolved via dynamic dns. I have the jvm configured properly to not cache dns.
My question is, I have the requirement that I need to log on the client the payload with the ip it was delivered to. Logging just the hostname will not work as the hostname to ip resolution is constantly changing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议从以下位置获取 CXF LoggingInInterceptor 的源代码:
http://svn.apache.org/repos/asf/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
并将其更新为套件您的需求。特别是,您需要从消息中获取 HttpServletREquest,并弄清楚如何从中获取 IP 以添加到日志中。 CXF 版本与协议无关(适用于 JMS 或其他协议),因此不会执行任何需要 HttpServletRequest 的 HTTP 特定操作。
I would suggest grabbing the source of the CXF LoggingInInterceptor from:
http://svn.apache.org/repos/asf/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
and update it to suite your needs. Particularly, you would need to grab the HttpServletREquest off the message and figure out how to get the IP off of it to add to the logs. The CXF version is protocol agnostic (would work for JMS or others) and thus doesn't do any of the HTTP specific things that would require the HttpServletRequest.