You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by learningtapestry <sa...@yahoo.com> on 2009/07/16 03:33:34 UTC

Log remote IP address with MDC class?

Is there any way to log the remote IP address using the log4j MDC. If I
contribute to RequestHandler inside my AppModule, I have a way of getting a
hold of the org.apache.tapestry5.services.Request, but from this Request,
there isn't no way of getting the IP address of the remote machine.

I don't want to add this my pages/components for various reasons.


public RequestFilter buildRequestLoggingFilter(){
    	return new RequestFilter(){
    		  public boolean service(Request request, Response response,
RequestHandler handler) throws IOException {
    			  MDC.put("remoteIP", ???????????? );
    			  return handler.service(request, response);
    		  }
    	};
    }




-- 
View this message in context: http://www.nabble.com/Log-remote-IP-address-with-MDC-class--tp24508725p24508725.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Log remote IP address with MDC class?

Posted by DH <ni...@gmail.com>.
Hi,

Have a try with

public RequestFilter buildRequestLoggingFilter(RequestGlobals requestGlobals){
}
, requestGlobals has the HttpServletRequest.

DH
http://www.gaonline.com.cn


----- Original Message ----- 
From: "learningtapestry" <sa...@yahoo.com>
To: <us...@tapestry.apache.org>
Sent: Thursday, July 16, 2009 9:33 AM
Subject: Log remote IP address with MDC class?


> 
> Is there any way to log the remote IP address using the log4j MDC. If I
> contribute to RequestHandler inside my AppModule, I have a way of getting a
> hold of the org.apache.tapestry5.services.Request, but from this Request,
> there isn't no way of getting the IP address of the remote machine.
> 
> I don't want to add this my pages/components for various reasons.
> 
> 
> public RequestFilter buildRequestLoggingFilter(){
>    return new RequestFilter(){
>      public boolean service(Request request, Response response,
> RequestHandler handler) throws IOException {
>      MDC.put("remoteIP", ???????????? );
>      return handler.service(request, response);
>      }
>    };
>    }
> 
> 
> 
> 
> -- 
> View this message in context: http://www.nabble.com/Log-remote-IP-address-with-MDC-class--tp24508725p24508725.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
>