To enable and configure the access logger, in set:

    Enabling the access logger

    Logback Configuration

    In addition to enabling the access logger, you have to add a logger for the specified or default logger name. For instance using the default logger name for logback:

    Logback configuration

    1. <appender
    2. name="httpAccessLogAppender"
    3. class="ch.qos.logback.core.rolling.RollingFileAppender">
    4. <append>true</append>
    5. <file>log/http-access.log</file>
    6. <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
    7. <!-- daily rollover -->
    8. </fileNamePattern>
    9. <maxHistory>7</maxHistory>
    10. </rollingPolicy>
    11. <encoder>
    12. <charset>UTF-8</charset>
    13. </encoder>
    14. </appender>
    15. <logger name="HTTP_ACCESS_LOGGER" additivity="false" level="info">
    16. <appender-ref ref="httpAccessLogAppender" />
    17. </logger>

    The pattern should only have the message marker as other elements will be processed by the access logger.

    Log Format

    The syntax is based on .

    Here are the supported markers:

    • %a - Remote IP address

    • %A - Local IP address

    • %b - Bytes sent, excluding HTTP headers, or ‘-‘ if no bytes were sent

    • %h - Remote host name

    • %H - Request protocol

    • %{<header>}i - Request header. If the argument is omitted (%i) all headers will be printed

    • %{<header>}o - Response header. If the argument is omitted (%o) all headers will be printed

    • %{<cookie>}c - Response cookie (SET_COOKIE). If the argument is omitted (%c) all cookies will be printed

    • %l - Remote logical username from identd (always returns ‘-‘)

    • %m - Request method

    • %p - Local port

    • %q - Query string (excluding the ‘?’ character)

    • %s - HTTP status code of the response

    • %{<format>}t - Date and time. If the argument is ommitted the Common Log Format format is used (“‘[‘dd/MMM/yyyy:HH:mm:ss Z’]‘“).

      • If the format starts with begin: (default) the time is taken at the beginning of the request processing. If it starts with end: it is the time when the log entry gets written, close to the end of the request processing.

      • The format should follow the DateTimeFormatter syntax.

    • %{property}u - Remote user that was authenticated. When micronaut-session is on the classpath, returns the session id if the argument is omitted or the specified property otherwise prints ‘-‘

    • %U - Requested URI

    • %v - Local server name

    • %D - Time taken to process the request, in millis

    • %T - Time taken to process the request, in seconds

    In addition, you can use the following aliases for commonly utilized patterns: