4. Monitoring, Logging and Statistics

accessLog

Version

Writes one access-log line per completed exchange through a Log4j appender. The line follows the Apache Common Log Format by default; add additionalPatternList entries to append your own SpEL-evaluated fields. Where the line is written and in which format is controlled by the Log4j configuration (log4j2.xml). Typically configured under global so it covers every API. See the examples under examples/logging/access.

Example Configuration

global:
- accessLog:
additionalPatternList:
- name: forwarded
expression: headers['x-forwarded-for']
global:
   - accessLog:
       additionalPatternList:
         - name: forwarded
           expression: headers['x-forwarded-for']

Syntax

accessLog:
additionalPatternList:
- <accessLog-scope>
dateTimePattern: <string>
defaultValue: <string>
excludePayloadSize: <boolean>
accessLog:
  additionalPatternList:
    - <accessLog-scope>
  dateTimePattern: <string>
  defaultValue: <string>
  excludePayloadSize: <boolean>

Attributes

NameRequiredDefaultDescriptionExamples
dateTimePatternfalsedd/MM/yyyy:HH:mm:ss ZPattern used to format the request timestamp in the log line.-
defaultValuefalse-Value logged when an exchange property or expression resolves to null.N/A
excludePayloadSizefalsefalseWhether to omit the payload size from the log line. Logging the size requires reading the whole body, which disables streaming; set to true to keep streaming.-

Child Structure

ElementCardinalityDescription
accessLog-scope0..*Extra fields appended to each log line. Each additionalVariable binds a name, referenced in log4j2.xml as %X{name}, to a SpEL expression evaluated against the exchange.

Can be used in