>From: Jonathan Mast >Subject: Problem with Custom Access Log Format >However, I would like to define a custom pattern for logging this information. >The problem is that I don't see a pattern code that corresponds to the User-Agent or to the Referrer.
Your reference (http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html#Access%20Log%20Val ve) lists the pattern codes you can use. %a - Remote IP address %A - Local IP address %b - Bytes sent, excluding HTTP headers, or '-' if zero %B - Bytes sent, excluding HTTP headers %h - Remote host name (or IP address if resolveHosts is false) %H - Request protocol %l - Remote logical username from identd (always returns '-') %m - Request method (GET, POST, etc.) %p - Local port on which this request was received %q - Query string (prepended with a '?' if it exists) %r - First line of the request (method and request URI) %s - HTTP status code of the response %S - User session ID %t - Date and time, in Common Log Format %u - Remote user that was authenticated (if any), else '-' %U - Requested URL path %v - Local server name %D - Time taken to process the request, in millis %T - Time taken to process the request, in seconds %I - current request thread name (can compare later with stacktraces) If you want anything not listed above, use one of the following pattern codes, replacing xxx with a header name: %{xxx}i for incoming request headers %{xxx}o for outgoing response headers %{xxx}c for a specific request cookie %{xxx}r xxx is an attribute in the ServletRequest %{xxx}s xxx is an attribute in the HttpSession >but I have a sneaky feeling that these values are accessible directly. You are correct. They are accessible directly. To pull values of the User-Agent and Referer headers from the request, you would add the following codes to your pattern %{User-Agent}i %{Referer}i As a reference the 'common' pattern is '%h %l %u %t "%r" %s %b'. The 'combined' pattern is '%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"' Compare the two patterns. 'combined' is effectively 'common' with the addition of '"%{Referer}i" "%{User-Agent}i"'. For anyone interested, the pattern codes listed above are the same ones used by Apache for configuring its access logs. - Bill --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]