Configuration
This page describes all available configuration options for logback-access-spring-boot-starter.
Application Properties
Configure the starter using Spring Boot properties in application.yml or application.properties:
logback:
access:
enabled: true
# config-location: classpath:custom-access.xml # Supports classpath: and file: prefixes
local-port-strategy: server
tomcat:
# request-attributes-enabled: true # Auto-detected from RemoteIpValve
tee-filter:
enabled: false
# include-hosts: localhost,example.com
# exclude-hosts: internal.example.com
# max-payload-size: 65536
# allowed-content-types:
# - "text/*"
# - "application/json"
filter:
# include-url-patterns:
# - /api/.*
exclude-url-patterns:
- /actuator/.*
- /healthProperty Reference
| Property | Default | Description |
|---|---|---|
logback.access.enabled | true | Enable or disable access logging |
logback.access.config-location | Auto-detected | Path to logback-access configuration file. Supports classpath: and file: URL prefixes |
logback.access.local-port-strategy | server | Port resolution strategy: server or local |
logback.access.tomcat.request-attributes-enabled | Auto-detected | Enable Tomcat request attributes. Auto-detected from RemoteIpValve when not set |
logback.access.tee-filter.enabled | false | Enable request/response body capture |
logback.access.tee-filter.include-hosts | null (all hosts) | Comma-separated list of hosts to include |
logback.access.tee-filter.exclude-hosts | null (none) | Comma-separated list of hosts to exclude |
logback.access.tee-filter.max-payload-size | 65536 | Maximum payload size (bytes) to log before suppression |
logback.access.tee-filter.allowed-content-types | null | Content-Type patterns allowed for body capture (override mode) |
logback.access.filter.include-url-patterns | null | URL patterns to include (regex) |
logback.access.filter.exclude-url-patterns | null | URL patterns to exclude (regex) |
Configuration File Resolution
When logback.access.config-location is set, that path is used directly (no fallback). If the specified file does not exist, the application will fail to start with an error.
When not set, the starter searches in the following order:
classpath:logback-access-test.xml(for testing)classpath:logback-access.xmlclasspath:logback-access-test-spring.xml(for testing with Spring features)classpath:logback-access-spring.xml- Built-in fallback configuration
XML Configuration
Basic Structure
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- Appenders define where logs go -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%h %l %u [%t] "%r" %s %b</pattern>
</encoder>
</appender>
<!-- Reference appenders to activate them -->
<appender-ref ref="console"/>
</configuration>Using Spring Properties
Inject Spring properties into your configuration:
<configuration>
<springProperty name="appName" source="spring.application.name"
defaultValue="app" scope="context"/>
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>[${appName}] %h %l %u [%t] "%r" %s %b</pattern>
</encoder>
</appender>
<appender-ref ref="console"/>
</configuration>Default Scope
The default scope for <springProperty> is LOCAL. Properties with LOCAL scope are only available during XML configuration processing for variable substitution (e.g., ${varName}). To access properties programmatically via context.getProperty(), set scope="context".
Using Spring Profiles
Configure different appenders for different environments:
<configuration>
<springProfile name="dev">
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%h %l %u [%t] "%r" %s %b %D</pattern>
</encoder>
</appender>
<appender-ref ref="console"/>
</springProfile>
<springProfile name="prod">
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>logs/access.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>logs/access.%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%h %l %u [%t] "%r" %s %b</pattern>
</encoder>
</appender>
<appender-ref ref="file"/>
</springProfile>
</configuration>Profile Expressions
Spring profile expressions support negation and multiple profiles:
<!-- Active when NOT in production -->
<springProfile name="!prod">
...
</springProfile>
<!-- Active in dev OR staging -->
<springProfile name="dev, staging">
...
</springProfile>File Appender
Write access logs to a file:
<appender name="file" class="ch.qos.logback.core.FileAppender">
<file>logs/access.log</file>
<encoder>
<pattern>%h %l %u [%t] "%r" %s %b</pattern>
</encoder>
</appender>Rolling File Appender
Rotate logs based on time or size:
<appender name="rolling" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>logs/access.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>logs/access.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>100MB</maxFileSize>
<maxHistory>30</maxHistory>
<totalSizeCap>3GB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>%h %l %u [%t] "%r" %s %b</pattern>
</encoder>
</appender>Disabling Access Logging
Set the property to disable access logging:
logback:
access:
enabled: falseOr use a Spring profile:
spring:
profiles:
active: test
---
spring:
config:
activate:
on-profile: test
logback:
access:
enabled: falseSee Also
- Tomcat Integration — Tomcat-specific properties and reverse proxy configuration
- Jetty Integration — Jetty-specific behavior and known limitations
- Advanced Topics — TeeFilter, URL filtering, JSON logging, and Spring Security