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:


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


<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"/>

In the access log, it will look like: - - [12/Nov/2007:16:39:48 +0000] "GET /styles/topmenu.css HTTP/1.1" 200 1184 "" "
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: