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
<appender
name="httpAccessLogAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<append>true</append>
<file>log/http-access.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
</fileNamePattern>
<maxHistory>7</maxHistory>
</rollingPolicy>
<encoder>
<charset>UTF-8</charset>
</encoder>
</appender>
<logger name="HTTP_ACCESS_LOGGER" additivity="false" level="info">
<appender-ref ref="httpAccessLogAppender" />
</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:
combined -
%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"
for Combined Log Format