Hi Rashmi,

What you use is ok, but it wont work for every case, in case of no proxy
used, %{x-forwarded-for}i; may not work ...

Regards

On 10/31/06, Li <[EMAIL PROTECTED]> wrote:

Hi Rashmi,

Thank you for sharing.

Have a nice day.

Li

On 10/31/06, Rashmi Rubdi <[EMAIL PROTECTED] > wrote:
>
> Hi Li,
>
> I'm sorry I should have re-referenced the AccessLogValve documentation
> earlier.
>
> I can still get this to work with the AccessLogValve custom pattern
> itself by adding the request header in this
> pattern element %{xxx}i , where xxx is the request header.
>
> The following also worked, as shown below:
>
>         <Valve className="org.apache.catalina.valves.AccessLogValve"
> directory="logs"
> pattern="%{x-forwarded-for}i; %H %u %t "%r" %s %b "%{Referer}i"
> "%{User-Agent}i""
> prefix="localhost_access_log." resolveHosts="false" suffix=".txt" />
>
> May be this kind of setup will slow down the performance of the site,
> but I'll probably disable the logging after getting an initial sample of
> search engine bots.
>
> Thanks for your suggestions and help, I will keep those in mind. I still
> need to learn Log4J and logging in general.
>
> But for now, this setup is sufficient.
>
> -Regards
> Rashmi
>
>
> ----- Original Message ----
> From: Li <[EMAIL PROTECTED]>
> To: Tomcat Users List <users@tomcat.apache.org>
> Sent: Monday, October 30, 2006 9:20:50 PM
> Subject: Re: Is it possible to log IP Address of requestor with custom
> AccessLogValve pattern?
>
>
> Hi Rashmi,
>
> You can creater your own log handler and pack it as jar and put it under
> tomcat lib dir, modify the loggin.properties file to have your handler
> work.
>
> Also, you can create your own request processor or intercepter to
> retrieve
> source ip from header and pass to logger.
>
> Regards
>
>
> On 10/31/06, Rashmi Rubdi < [EMAIL PROTECTED]> wrote:
> >
> > I think my web site is behind a proxy, I was told that
> > request.getHeader("x-forwarded-for") should work instead of
> > request.getRemoteAddr() , and it does work when I try it.
> >
> > The site correctly shows the remote client's IP Address.
> >
> > I guess there's no pattern element in Access Log Valve for capturing
> the
> > x-forwarded-for.
> >
> > I might have to log it with Log4J.
> >
> > Sincerely
> > -Rashmi
> > ----- Forwarded Message ----
> > From: Rashmi Rubdi < [EMAIL PROTECTED]>
> > To: Tomcat Users List <users@tomcat.apache.org>
> > Sent: Monday, October 30, 2006 5:03:44 PM
> > Subject: Re: Is it possible to log IP Address of requestor with custom
>
> > AccessLogValve pattern?
> >
> >
> > Hi Li and Pid,
> >
> > Thanks again for your replies.
> >
> > You are right, I also tried printing request.getRemoteAddr() in a JSP,
> and
> > it always lists 127.0.0.1
> >
> > As you have suggested my site could be behind a proxy, but I don't
> know
> > this for sure. I've asked the host provider if this is the case and
> waiting
> > for a reply.
> >
> > I also use Javascript based logging but that only logs requests coming
> > from a browser and correctly logs the IP address of the requestor
> however,
> > it does not log
> > search engine bots I guess because bots disable Javascript or can't
> work
> > with Javascript.
> >
> > -Regards
> > Rashmi
> >
> > ----- Original Message ----
> > From: Li <[EMAIL PROTECTED]>
> > To: Tomcat Users List < users@tomcat.apache.org>; [EMAIL PROTECTED]
> > Sent: Monday, October 30, 2006 8:39:12 AM
> > Subject: Re: Is it possible to log IP Address of requestor with custom
>
> > AccessLogValve pattern?
> >
> >
> > Hi Rashmi,
> >
> > if there is problem with retrieving correct remote IP address, log4j
> will
> > not solve problem ...
> >
> > it seems like this:
> >
> > remote user ---(send request) ---> your proxy (or maybe you use some
> > connector or forwardor) ----> tomcat
> >
> > if 127.0.0.1, seems your connector or forwardoer is located in the
> same
> > host
> > as your tomcat sharing same IP address or hostname
> >
> > if not 127.0.0.1, seems the request comes from proxy
> >
> >
> >
> > On 10/30/06, Pid < [EMAIL PROTECTED]> wrote:
> > >
> > > Do you have a local proxy between the tomcat instance and the
> requestor?
> > >
> > >
> > >
> > > Rashmi Rubdi wrote:
> > > > Li,
> > > >
> > > > Thanks for the reply.
> > > >
> > > > As indicated in your illustration,  in your case the remote IP
> address
> > > (IP of the client browser) is correctly displaying.
> > > >
> > > > But in my case, for some reason even when my website is accessed
> > > remotely it always shows local IP Address (the website's IP address)
> and
> > not
> > > the remote IP address.
> > > >
> > > > In other words
> > > > %a %A %h  is translating *always* to
> > > > 127.0.0.1
> > > > 68.120.115.43
> > > > 127.0.0.1
> > > >
> > > > Where 68.120.115.43  is the IP address of the website host and not
> the
> > > client (remote host).
> > > >
> > > > The website is hosted on a Tomcat 5.5 which is configured as a
> virtual
> > > host. I wonder if the virtual host setting might be the cause for
> not
> > > logging the actual remote IP address.
> > > >
> > > > If I can't get Access Log Valve to log the remote IP address then
> I
> > > might have to try it with Log4J with Commons Logging to log the
> remote
> > IP
> > > address I guess.
> > > >
> > > > -Regards
> > > > Rashmi
> > > >
> > > > ----- Original Message ----
> > > > From: Li <[EMAIL PROTECTED] >
> > > > To: Tomcat Users List <users@tomcat.apache.org>
> > > > Sent: Monday, October 30, 2006 3:25:38 AM
> > > > Subject: Re: Is it possible to log IP Address of requestor with
> custom
> > > AccessLogValve pattern?
> > > >
> > > >
> > > > what you defined is correct ...  a simpler way is using default
> > setting
> > > > <Valve
> > > >                   className="
> org.apache.catalina.valves.AccessLogValve
> > "
> > > >                   directory="logs"
> > > >                   prefix="your-site-access-log-"
> > > >                   suffix=".log"
> > > >                   pattern="common"
> > > >                   resolveHosts="false"/>
> > > >
> > > > the result should be
> > > > (if you are testing from same host)
> > > > 127.0.0.1 - - [18/Oct/2006:18:54:48 +0800] "GET /site/ HTTP/1.1"
> 200
> > 306
> > > > 127.0.0.1 - - [18/Oct/2006:18:54:48 +0800] "GET /site/Welcome.do
> > > HTTP/1.1"
> > > > 200 1775
> > > > (if your user testing from remote host)
> > > > 202.110.6.23 - - [18/Oct/2006:19:03:44 +0800] "GET
> /site/Welcome.do
> > > > HTTP/1.1" 200 8893
> > > > ...
> > > >
> > > > On 10/30/06, Rashmi Rubdi <[EMAIL PROTECTED]> wrote:
> > > >> Hello,
> > > >>
> > > >> My site is hosted on Tomcat 5.5 and I'm trying to log the IP
> Address
> > of
> > > >> search engine bots that crawl the site.
> > > >>
> > > >> After reading the following documentation here, which is written
> very
> > > >> nicely btw
> > > >> http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html
> > > >>
> > > >>
> > >
> > 
http://tomcat.apache.org/tomcat-5.5-doc/catalina/docs/api/org/apache/catalina/valves/AccessLogValve.html
>
> > > >>
> > > >> I configured the pattern attribute of AccessLogValve as follows:
> > > >>
> > > >> <Valve className="org.apache.catalina.valves.AccessLogValve "
> > > >> directory="logs"
> > > >> pattern="%a %A %h %H %u %t "%r" %s %b "%{Referer}i"
> "%{User-Agent}i""
> > > >> prefix="localhost_access_log." resolveHosts="false" suffix=".txt"
> />
> > > >>
> > > >> The following is a sample of what gets logged with the above
> > > configuration
> > > >> in server.xml .
> > > >>
> > > >> 127.0.0.1 68.120.115.43 127.0.0.1 HTTP/1.1 -
> [29/Oct/2006:23:50:13
> > > -0800]
> > > >> "GET /web/_stylesheet/table.css HTTP/1.1" 304 - "
> > > >> http://www.website.com/c/a_page.jsp";;;;; "Mozilla/5.0 (Windows;
> U;
> > Windows
> > > NT
> > > >> 5.1; en-US; rv: 1.8.0.7) Gecko/20060909 Firefox/1.5.0.7"
> > > >>
> > > >> The documentation says that %a is Remote IP Address, however
> > 127.0.0.1is
> > > >> being logged instead of the IP Address of the requestor.
> > > >>
> > > >> Is this correct?
> > > >>
> > > >> IMO %a should be the IP Address of the agent that's making the
> > request
> > > - (
> > > >> i.e. the IP Address of a browser or a bot etc).
> > > >>
> > > >> Please let me know if there's a way to log IP Address of the
> agent
> > > that's
> > > >> making the request.
> > > >>
> > > >> Any help is appreciated.
> > > >>
> > > >> -Thank you
> > > >> Rashmi
> > > >>
> > > >>
> > > >>
> > > >>
> ---------------------------------------------------------------------
> > > >> To start a new topic, e-mail: users@tomcat.apache.org
> > > >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > >> For additional commands, e-mail: [EMAIL PROTECTED]
> > > >>
> > > >>
> > > >
> > > >
> > >
> > >
> > >
> ---------------------------------------------------------------------
> > > To start a new topic, e-mail: users@tomcat.apache.org
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> >
> >
> > --
> > When we invent time, we invent death.
> >
> >
> >
> > ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@tomcat.apache.org
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> > ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@tomcat.apache.org
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
> When we invent time, we invent death.
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


--
When we invent time, we invent death.




--
When we invent time, we invent death.

Reply via email to