如何在JBoss上记录ip地址 [英] How to log ip address on JBoss

查看:105
本文介绍了如何在JBoss上记录ip地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想记录调用我的WS的客户端的IP地址。

I want to log the IP address of the client who is calling my WS.

我怎样才能在JBoss上执行此操作?

How can I do that on JBoss?

编辑:

如果可能,我想在JBOSS上使用log4J配置。

I would like to use log4J configuration on JBOSS if possible.

推荐答案

将以下内容添加到log4j配置xml中的转换模式参数中。

Append the following to your conversion pattern parameter in log4j configuration xml.

%X{RemoteAddress}

在您的代码中,您可以记录IP地址如下:

And in your code you can log the ip address as follows:

MDC.put("RemoteAddress", request.getRemoteAddr())

这篇关于如何在JBoss上记录ip地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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