Tech Tip: How to add local IP address and hostname to the local_access_log
Spectrum Tech Tip posted by Senior Support Engineer, Bill Wolforth on 10-7-2014
Description:
By default we display in the $SPECROOT/tomcat/local_access_log the following information based upon the pattern variables.
%l - Remote logical username from identd (always returns '-')
%u - Remote user that was authenticated
%t - Date and time, in Common Log Format format
%r - First line of the request
%s - HTTP status code of the response
%b - Bytes sent, excluding HTTP headers, or '-' if no bytes were sent
%D - Time taken to process the request, in milliseconds
This looks like the following below:
- spectrum [01/Mar/2014:00:00:05 -0500] POST /spectrum/common/poll?requestID=27116 HTTP/1.1 200 821 0
However no local IP address or hostnames are shown.
Solution:
In order to add local IP address and hostname to the local_access_log please make the following changes.
- From the OneClick server, make a backup copy of $SPECROOT/tomcat/conf/server.xml
- With an XML editor of your choice find the following line:
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="%l %u %t %r %s %b %D" resolveHosts="false" /> - After the pattern= statement please add %A %v so the final version looks pattern="%A %v %l %u %t %r %s %b %D"
- Save and after restart of the tomcat you will now see local IP address and local server name appended to all output.
130.x.x.x localhost - spectrum [14/Mar/2014:00:00:04 -0400] POST /spectrum/common/clearConfigs HTTP/1.1 200 58 0
Additional options can be added or changed from the tomcat accesslogvalve settings here
http://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/catalina/valves/AccessLogValve.html