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

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 29: Line 29:


The functionality is similar to Tomcat's <tt>AccessLogValve</tt>. For more details see [[Tomcat Configuration]].
The functionality is similar to Tomcat's <tt>AccessLogValve</tt>. For more details see [[Tomcat Configuration]].
=Request Duration Recording=


=Configurable Attributes=
=Configurable Attributes=

Revision as of 23:14, 11 May 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

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
  • %t date and time, in Common Log Format format
  • %u remote user that was authenticated
  • %U requested URL path
  • %v local server name

%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).