简体   繁体   English

记录在CXF中解析的主机名

[英]Logging hostname resolved in CXF

I have a java web service client that uses CXF. 我有一个使用CXF的Java Web服务客户端。 The server has 10+ possible ips that are resolved via dynamic dns. 该服务器有10多个可能的ip,这些ip可通过动态dns解析。 I have the jvm configured properly to not cache dns. 我已经正确配置了jvm以不缓存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. 我的问题是,我有一个要求,我需要用交付的IP登录有效负载。 Logging just the hostname will not work as the hostname to ip resolution is constantly changing. 仅注册主机名将不起作用,因为ip解析的主机名不断变化。

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 我建议从以下位置获取CXF LoggingInInterceptor的源: http : //svn.apache.org/repos/asf/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor。爪哇

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. 特别是,您将需要从消息中获取HttpServletREquest,并弄清楚如何从中获取IP以添加到日志中。 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. CXF版本与协议无关(适用于JMS或其他版本),因此不会执行任何需要HttpServletRequest的HTTP特定操作。

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

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