Skip to content

patgpraj/spring-boot-ext-logback-access

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spring-boot-ext-logback-access

Maven Central CircleCI

Spring Boot Extension: Logback-access Auto Configuration.

Requirements

  • 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+

Usage

Maven dependency

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>

Logback-access configuration

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

Access logging

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

Configuration properties

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

Related articles

Contributing

Bug reports and pull requests are welcome :)

License

Licensed under the Apache License, Version 2.0.

About

Spring Boot Extension: Logback-access Auto Configuration

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 99.5%
  • HTML 0.5%