Undertow WildFly Subsystem Configuration - access-log: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(48 intermediate revisions by the same user not shown)
Line 4: Line 4:


=Overview=
=Overview=
This page documents the configuration of the Undertow <tt>AccessLogHandler</tt>. The handler generates log entries for each request. The handler can log any attributed that is provided with the <tt>ExchangeAttribute</tt> mechanism. The most common are presented below in the [[#Log_Patterns|Log Patterns]] section.


<pre>
<pre>
Line 25: Line 27:
  </subsystem>
  </subsystem>
</pre>
</pre>
The functionality is similar to Tomcat's <tt>AccessLogValve</tt>. For more details see [[Tomcat Configuration]].
=Request Duration Recording=
record-request-start-time="true"
must be specified in order for %D and %T access log elements to work. For more details see access-log %D and access-log %T. Note that both ajp-listener and http-listener are used, record-request-start-time="true" must be set on both of them.


=Configurable Attributes=
=Configurable Attributes=


==pattern==
==pattern==
<pre>
<access-log pattern='%h %l %u %t "%r" %s %b %D'/>
</pre>
Alternative syntax (note the <tt>&amp;quot;</tt> usage):
<pre>
<access-log pattern="%I %h %l %u %t &amp;quot;%r&amp;quot; %s %b %D"/>
</pre>


The default value is "common".
The default value is "common".
Line 61: Line 82:


==predicate==
==predicate==
=Log Patterns=
==Named Patterns==
"<tt>common</tt>": <tt>%h %l %u %t "%r" %s %b</tt>
"<tt>combined</tt>": <tt> %h %l %u %t "%r" %s %b "%{i,Referer}" "%{i,User-Agent}"</tt>
==Pattern Elements==
* <tt>%a</tt> remote IP address
* <tt>%A</tt> local IP address
* <tt>%b</tt> bytes sent, excluding HTTP headers, or '-' if no bytes were sent
* <tt>%B</tt> bytes sent, excluding HTTP headers
* <tt>%h</tt> remote host name
* <tt>%H</tt> request protocol
* <tt>%l</tt> remote logical username from identd (always returns '-')
* <tt>%m</tt> request method
* <tt>%p</tt> local port
* <tt>%q</tt> query string (excluding the '?' character)
* <tt>%r</tt> first line of the request
* <tt>%s</tt> HTTP status code of the response
* <tt>%S</tt> Bytes transferred (received and sent), including request and headers. It cannot be zero.
* <tt>%u</tt> remote user that was authenticated
* <tt>%U</tt> requested URL path
* <tt>%v</tt> local server name
===%t===
Date and time, in Common Log Format format:
<pre>
[18/Sep/2011:19:18:28 -0400]
</pre>
The last number indicates the timezone offset from GMT.
Note that if the brackets are not explicitly specified, WildFly still generates them in the log; <tt>%t</tt> and <tt>[%t]</tt> generate the same output, bracket-enclosed.
<blockquote style="background-color: Gold; border: solid thin Goldenrod;">
:<br>Empirical evidence seems to suggest that the timestamp contained by the log entry represents the moment when ''the request is logged'', not when it lands onto the server. This is relevant for long running requests, where the "landing time" can be calculated with %t - %T.<br><br>
</blockquote>
Also see:
<blockquote style="background-color: #f9f9f9; border: solid thin lightgrey;">
:[[Httpd_Logging_Configuration#.25t|httpd Timestamp Logging]]
</blockquote>
===%D===
Time taken to process the request, in milliseconds.
Note that %D won't return the request processing time, but "-" unless the <tt>http-listener</tt>'s and <tt>ajp-listener</tt>'s <tt>record-request-start-time</tt> is set to <tt>"true"</tt>. Also see [[Undertow WildFly Subsystem Configuration#record-request-start-time|record-request-start-time]].
===%T===
Time taken to process the request, in seconds. It won't work unless <tt>record-request-start-time</tt> is set to true, see [[#.25D|%D]] above.
===%I===
Current request thread name
The handler can also log cookie, header or session information. The patterns are borrowed from the apache log syntax:
===Incoming Headers===
<tt>%{i,xxx}</tt>
===Outgoing Response Headers===
<tt>%{o,xxx}</tt>
===Cookies===
<tt>%{c,xxx}</tt>
===Attribute in ServletRequest===
<tt>%{r,xxx} xxx</tt>
===Attribute in HttpSession===
<tt>%{s,xxx} xxx</tt>
For more details on Apache log pattern syntax, see:
<blockquote style="background-color: #f9f9f9; border: solid thin lightgrey;">
:[[Httpd Logging Configuration|httpd Logging Configuration]]
</blockquote>
=Implementation Details=
The functionality is implemented by <tt>io.undertow.server.handlers.accesslog.AccessLogHandler</tt> (https://github.com/undertow-io/undertow/blob/master/core/src/main/java/io/undertow/server/handlers/accesslog/AccessLogHandler.java).

Latest revision as of 15:57, 15 December 2016

Internal

Overview

This page documents the configuration of the Undertow AccessLogHandler. The handler generates log entries for each request. The handler can log any attributed that is provided with the ExchangeAttribute mechanism. The most common are presented below in the Log Patterns section.

<subsystem xmlns="urn:jboss:domain:undertow:3.0">

   ...

   <server name="default-server">
      ...
      <host name="default-host" alias="localhost">
         <location name="/" .../>
         <access-log/>
         ...
      </host>
   </server>

   <servlet-container .../>

   ...

 </subsystem>

The functionality is similar to Tomcat's AccessLogValve. For more details see Tomcat Configuration.

Request Duration Recording

record-request-start-time="true" must be specified in order for %D and %T access log elements to work. For more details see access-log %D and access-log %T. Note that both ajp-listener and http-listener are used, record-request-start-time="true" must be set on both of them.

Configurable Attributes

pattern

<access-log pattern='%h %l %u %t "%r" %s %b %D'/>

Alternative syntax (note the &quot; usage):

<access-log pattern="%I %h %l %u %t &quot;%r&quot; %s %b %D"/>

The default value is "common".

worker

The default value is "default".

directory

The default value is "${jboss.server.log.dir}"

relative-to

The default value is "access_log"

suffix

The default value is ".log"

rotate

The default value is "true"

use-server-log

The default value is "false"

extended

The default value is "false"

predicate

Log Patterns

Named Patterns

"common": %h %l %u %t "%r" %s %b

"combined": %h %l %u %t "%r" %s %b "%{i,Referer}" "%{i,User-Agent}"

Pattern Elements

  • %a remote IP address
  • %A local IP address
  • %b bytes sent, excluding HTTP headers, or '-' if no bytes were sent
  • %B bytes sent, excluding HTTP headers
  • %h remote host name
  • %H request protocol
  • %l remote logical username from identd (always returns '-')
  • %m request method
  • %p local port
  • %q query string (excluding the '?' character)
  • %r first line of the request
  • %s HTTP status code of the response
  • %S Bytes transferred (received and sent), including request and headers. It cannot be zero.
  • %u remote user that was authenticated
  • %U requested URL path
  • %v local server name

%t

Date and time, in Common Log Format format:

[18/Sep/2011:19:18:28 -0400]

The last number indicates the timezone offset from GMT.

Note that if the brackets are not explicitly specified, WildFly still generates them in the log; %t and [%t] generate the same output, bracket-enclosed.


Empirical evidence seems to suggest that the timestamp contained by the log entry represents the moment when the request is logged, not when it lands onto the server. This is relevant for long running requests, where the "landing time" can be calculated with %t - %T.

Also see:

httpd Timestamp Logging

%D

Time taken to process the request, in milliseconds.

Note that %D won't return the request processing time, but "-" unless the http-listener's and ajp-listener's record-request-start-time is set to "true". Also see record-request-start-time.

%T

Time taken to process the request, in seconds. It won't work unless record-request-start-time is set to true, see %D above.

%I

Current request thread name

The handler can also log cookie, header or session information. The patterns are borrowed from the apache log syntax:

Incoming Headers

%{i,xxx}

Outgoing Response Headers

%{o,xxx}

Cookies

%{c,xxx}

Attribute in ServletRequest

%{r,xxx} xxx

Attribute in HttpSession

%{s,xxx} xxx


For more details on Apache log pattern syntax, see:

httpd Logging Configuration

Implementation Details

The functionality is implemented by io.undertow.server.handlers.accesslog.AccessLogHandler (https://github.com/undertow-io/undertow/blob/master/core/src/main/java/io/undertow/server/handlers/accesslog/AccessLogHandler.java).