register
other register

Monday, November 12, 2007

Enable logging remote host name is tomcat access log.

To enable remote host name to be logged in tomcat access log, in conf/server.xml, you have to do two things:

1.

<Service name="Catalina">
...
<Connector port="8080" ... enableLookups="true"..>
...
<Service>


2.

<Host name="localhost" ..>
...
<Valve className="org.apache.catalina.valves.FastCommonAccessLogValve"
directory="logs" prefix="access_log." suffix=".txt"
pattern="combined" resolveHosts="true" rotatable="true" fileDateFormat="yyyy-MM-dd"/>
...
</Host>


In the access log, it will look like:


host217-43-97-182.range217-43.btcentralplus.com - - [12/Nov/2007:16:39:48 +0000] "GET /styles/topmenu.css HTTP/1.1" 200 1184 "http://www.jetonrails.com" "
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1)"

The first part is the remote host name instead of remote IP address.

No comments: