https://github.com/itzg/try-spring-boot-logging-to-fluentd
Spring Boot application configured with "more logback appenders" to send logs to fluentd using fluency
https://github.com/itzg/try-spring-boot-logging-to-fluentd
Last synced: about 1 month ago
JSON representation
Spring Boot application configured with "more logback appenders" to send logs to fluentd using fluency
- Host: GitHub
- URL: https://github.com/itzg/try-spring-boot-logging-to-fluentd
- Owner: itzg
- License: mit
- Created: 2019-08-01T19:00:30.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-01T19:13:18.000Z (almost 7 years ago)
- Last Synced: 2026-01-20T13:44:31.619Z (6 months ago)
- Language: Java
- Size: 50.8 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
This Spring Boot application is configured with [more logback appenders](https://github.com/sndyuk/logback-more-appenders) to send logs to [fluentd](https://docs.fluentd.org/) using [fluency](https://github.com/komamitsu/fluency).
The application declares two schedule methods to simulate some activity to log. One method logs at info-level the current time every second. The other method logs an exception with stack trace every 10 seconds at warning level.
# Usage
## Start fluentd
This repository includes a [Docker Compose file](docker-compose.yml) that declares a fluentd service bound to the default fluentd port, 24224. To start the service run:
```
docker-compose up -d
```
## Start the application
```
./mvnw spring-boot:run
```
You won't see anything after the initial banner since the only appender configured sends to fluend.
## Check fluentd for the application logs
```
docker exec try-spring-boot-logging-to-fluentd_fluentd_1 tail -f /fluentd/log/data.log
```
# How it works
The logback configuration for fluentd is located in [fluency.xml](src/main/resources/fluency.xml) and that is included by [logback-spring.xml](src/main/resources/logback-spring.xml). That approach to customizing log configuration in Spring Boot is described in the [logging chapter of the Spring Boot reference](https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-logging.html#boot-features-custom-log-configuration).