Spring Boot Extension: Logback-access Auto Configuration.
- Java 8+
- Spring Boot 1.3.0+ (web application)
- Any of the following servlet containers:
- Embedded Tomcat 8.0.28+
- Embedded Jetty 9.2.14+
- Logback-access 1.1.6+
This artifacts are in the Maven central repository.
To use this extension on Maven-based projects, use following dependency.
<dependencies>
<dependency>
<groupId>net.rakugakibox.springbootext</groupId>
<artifactId>spring-boot-ext-logback-access</artifactId>
<version>1.6</version>
</dependency>
</dependencies>
This extension requires Logback-access version 1.1.6 or higher.
If you use Spring Boot version 1.3.0 - 1.3.3, specify the version of Logback-access.
For example on Maven-based projects:
<properties>
<logback.version>1.1.7</logback.version>
</properties>
Create a Logback-access configuration file to classpath:logback-access.xml
.
For example:
<configuration>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>common</pattern>
</encoder>
</appender>
<appender-ref ref="CONSOLE" />
</configuration>
See Also: Logback-access configuration - Logback-access
When access the WEB application, it is logged.
For example:
192.168.35.1 - - [14/5/2016:17:59:54 +0900] "GET / HTTP/1.1" 200 241
192.168.35.1 - - [14/5/2016:18:00:32 +0900] "GET /favicon.ico HTTP/1.1" 200 946
192.168.35.1 - - [14/5/2016:18:01:21 +0900] "GET / HTTP/1.1" 304 0
logback.access:
# Enable Logback-access Auto Configuration.
# Defaults to true.
enabled: true
# The location of the configuration file.
# Auto-detected by default:
# => "classpath:logback-access-test.xml"
# => "classpath:logback-access.xml"
# => "classpath:net/rakugakibox/springbootext/logback/access/logback-access.xml"
config: "classpath:your-logback-access.xml"
# Use the server port (HttpServletRequest#getServerPort())
# instead of the local port (HttpServletRequest#getLocalPort()), in IAccessEvent#getLocalPort().
# Defaults to true.
useServerPortInsteadOfLocalPort: true
# for Tomcat.
tomcat:
# Enable request attributes to work with the RemoteIpValve enabled with server.useForwardHeaders.
# Defaults to the the presence of the RemoteIpValve.
enableRequestAttributes: true
- Provide auto-configuration for logback-access - Issue #2609 - spring-projects/spring-boot - GitHub
- Spring Boot: Logback-access が使いやすくなる自動設定を作って公開した - rakugakibox.net
Bug reports and pull requests are welcome :)
Licensed under the Apache License, Version 2.0.