All Projects → akihyro → Logback Access Spring Boot Starter

akihyro / Logback Access Spring Boot Starter

Licence: apache-2.0
Spring Boot Starter for Logback-access

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Logback Access Spring Boot Starter

Logbook
An extensible Java library for HTTP request and response logging
Stars: ✭ 822 (+596.61%)
Mutual labels:  spring-boot, spring-boot-starter, logging, logger
Spring Higher Order Components
⚡️ Preconfigured components to speedup Spring Boot development
Stars: ✭ 65 (-44.92%)
Mutual labels:  spring-boot, spring-boot-starter, logging
Log Viewer
Web UI to viewing logs
Stars: ✭ 59 (-50%)
Mutual labels:  spring-boot, logging, logger
logback-access-spring-boot-starter
Spring Boot Starter for Logback-access.
Stars: ✭ 153 (+29.66%)
Mutual labels:  logback, logger, spring-boot-starter
Loguru
Python logging made (stupidly) simple
Stars: ✭ 10,510 (+8806.78%)
Mutual labels:  logging, logger
Serverlog
A simple, practical and innovative Node.js log library that enables you to view logs in Chrome dev tools and browser Console.
Stars: ✭ 117 (-0.85%)
Mutual labels:  logging, logger
Silencer
Easily suppress the Rails logger
Stars: ✭ 116 (-1.69%)
Mutual labels:  logging, logger
Disruptor Spring Boot Starter
starter for disruptor
Stars: ✭ 83 (-29.66%)
Mutual labels:  spring-boot, spring-boot-starter
Bulk
👨‍💻 Bulk is a library for buffering the objects. Pipeline(Sink) receives the object and emits the object bulked.
Stars: ✭ 59 (-50%)
Mutual labels:  logging, logger
Telegram Spring Boot Starter
Telegram Bot API Spring Boot Starter
Stars: ✭ 79 (-33.05%)
Mutual labels:  spring-boot, spring-boot-starter
React Native Logs
Performance-aware simple logger for React-Native with namespaces, custom levels and custom transports (colored console, file writing, etc.)
Stars: ✭ 84 (-28.81%)
Mutual labels:  logging, logger
Android Filelogger
A general-purpose logging library with built-in support to save logs to file efficiently.
Stars: ✭ 70 (-40.68%)
Mutual labels:  logging, logger
Logsip
A simple, concise, colorful logger for Go
Stars: ✭ 94 (-20.34%)
Mutual labels:  logging, logger
Node Lambda Log
Basic logging mechanism for Node 6.10+ Lambda Functions
Stars: ✭ 115 (-2.54%)
Mutual labels:  logging, logger
Logback More Appenders
Extra appenders for Logback.
Stars: ✭ 93 (-21.19%)
Mutual labels:  logger, logback
Springboot Templates
springboot和dubbo、netty的集成,redis mongodb的nosql模板, kafka rocketmq rabbit的MQ模板, solr solrcloud elasticsearch查询引擎
Stars: ✭ 100 (-15.25%)
Mutual labels:  spring-boot, logback
Spring Boot Sample App
Sample app generated from my spring boot archtype on :https://github.com/Romeh/spring-boot-quickstart-archtype
Stars: ✭ 81 (-31.36%)
Mutual labels:  spring-boot, logback
Lilith
Lilith is a Logging- and AccessEvent viewer for Logback, log4j, log4j2 and java.util.logging
Stars: ✭ 111 (-5.93%)
Mutual labels:  logging, logback
Log
Structured logging package for Go.
Stars: ✭ 1,094 (+827.12%)
Mutual labels:  logging, logger
Yii2 Psr Log Target
Yii 2.0 log target that is able to write messages to PSR-3 compatible logger
Stars: ✭ 58 (-50.85%)
Mutual labels:  logging, logger

logback-access-spring-boot-starter

Maven Central javadoc.io CircleCI Codecov License

Spring Boot Starter for Logback-access.

Note: This page is for Spring Boot 2. If you use Spring Boot 1, please refer to v2.6.x branch.
Note: This artifact name was changed in v2.0.0. The old name is "spring-boot-ext-logback-access".

Features

  • Auto-detects your configuration file and configures Logback-access.
  • Supports configuration files on the classpath.
  • Supports X-Forwarded-* HTTP headers.
  • Supports HttpServletRequest#getRemoteUser() provided by Spring Security.
  • Provides extensions of configuration file.
    • <springProfile> tag.
    • <springProperty> tag.

Supported versions

"logback-access-spring-boot-starter" supports the following versions.
Other versions might also work, but we have not tested it.

  • Java 8
  • Spring Boot 2.0.0
  • Embedded Tomcat 8.5.28
  • Embedded Jetty 9.4.8
  • Embedded Undertow 1.4.22
  • Logback-access 1.2.3

Usage

Adding the dependency

"logback-access-spring-boot-starter" is published on Maven Central Repository.
If you are using Maven, add the following dependency.

<dependency>
    <groupId>net.rakugakibox.spring.boot</groupId>
    <artifactId>logback-access-spring-boot-starter</artifactId>
    <version>2.7.1</version>
</dependency>

Configuring the Logback-access

Create a Logback-access configuration file "logback-access.xml" in the root of the classpath.

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 the Logback official documents:

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

Auto-detection of configuration file

Priority order

"logback-access-spring-boot-starter" will look for the configuration file in the following order.
The first found configuration file will be used.

  1. "logback-access-test.xml" in the root of the classpath.
  2. "logback-access.xml" in the root of the classpath.
  3. "logback-access-test-spring.xml" in the root of the classpath.
  4. "logback-access-spring.xml" in the root of the classpath.
  5. fallback configuration file (appends to standard output with common pattern).

Separation for testing

If you are using Maven and place "logback-access-test.xml" under the "src/test/resources" folder, Maven does not include it in the artifact.
Thus, you can use a different configuration file "logback-access-test.xml" during testing and another file "logback-access.xml" in production.
This is the same concept as Logback configuration ("logback.xml" and "logback-test.xml").

Extensions of configuration file

<springProfile> tag: Profile-specific configuration

The <springProfile> tag allows you to optionally include or exclude sections of configuration based on the active Spring profiles.
Usage of this extension follows Spring Boot Logback extension "Profile-specific configuration".

<springProfile name="staging">
    <!-- configuration to be enabled when the "staging" profile is active -->
</springProfile>

<springProfile name="dev, staging">
    <!-- configuration to be enabled when the "dev" or "staging" profiles are active -->
</springProfile>

<springProfile name="!production">
    <!-- configuration to be enabled when the "production" profile is not active -->
</springProfile>

<springProperty> tag: Environment properties

The <springProperty> tag allows you to surface properties from the Spring Environment.
Usage of this extension follows Spring Boot Logback extension "Environment properties".

<springProperty scope="context" name="fluentHost" source="myapp.fluentd.host" defaultValue="localhost" />
<appender name="FLUENT" class="ch.qos.logback.more.appenders.DataFluentAppender">
    <remoteHost>${fluentHost}</remoteHost>
    ...
</appender>

Configuration properties

"logback-access-spring-boot-starter" provides the following configuration properties.
These can be configure by your "application.yml" / "application.properties".

logback.access:
  # Whether to enable auto-configuration.
  # Defaults to true.
  enabled: true
  # The location of the configuration file.
  # Auto-detected by default:
  #   1. "classpath:logback-access-test.xml"
  #   2. "classpath:logback-access.xml"
  #   3. "classpath:logback-access-test-spring.xml"
  #   4. "classpath:logback-access-spring.xml"
  #   5. "classpath:net/rakugakibox/spring/boot/logback/access/logback-access-spring.xml"
  config: "classpath:your-logback-access.xml"
  # Whether to use the server port (HttpServletRequest#getServerPort())
  # instead of the local port (HttpServletRequest#getLocalPort()) within IAccessEvent#getLocalPort().
  # Defaults to true.
  useServerPortInsteadOfLocalPort: true
  # for Tomcat.
  tomcat:
    # Whether to enable request attributes to work with the RemoteIpValve enabled with "server.useForwardHeaders".
    # Defaults to the presence of the RemoteIpValve.
    enableRequestAttributes: true

Release notes

Please refer to the "Releases" page.

Related articles

Contributing

Bug reports and pull requests are welcome :)

Building and testing

To build and test, you can run:

$ cd logback-access-spring-boot-starter
$ ./mvnw clean install

License

Licensed under the Apache License, Version 2.0.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].