views:

69

answers:

2

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

How can I do that on JBoss?

EDIT:

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

A: 

Read this, in case you are provind functionality via EJB3.

thelost
Thx for the answer. But I am not using EJB3, and I would like to log it using log4j conf on jboss
Diego Dias
+2  A: 

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

%X{RemoteAddress}

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

MDC.put("RemoteAddress", request.getRemoteAddr())
Sasi
The code should also "unset" the MDC once the request has completed.
skaffman
Here is a short article on the use of MDC in jboss: http://community.jboss.org/wiki/LoggingContextualInformation
Janek Bogucki