This project serves as a practical example for understanding how a logging aggregation system pipeline works in a distributed runtime environment and Logback configuration in the context of a Spring-boot application. The configuration set in this example is for learning purposes and should not be used in a production environment.
This repository contains the source code for two articles, which provides a more detailed explanation:
To build and run this project, ensure you have the following installed:
- Java 17
- Docker and Docker-Compose V2
Before running the project, build the fluentd
image for the first time by executing the following commands:
cd fluentd-image-build
docker build -t custom-fluentd:latest ./
These commands generate the image with all the necessary plugins for the project. If interested, inspect the files inside the "fluentd-image-build" folder or refer to the following links for more information:
For a deeper understanding of how to configure Logback, consider modifying the files logback-access-spring.xml or logback-spring.xml located inside the resources package
Refer to my article Undestanding Logback to lear more about how to configure Logback. Modify what you want to later see the result in Kibana.
The first time you run the project or whenever you make changes to the source code, generate the .jar
files needed to execute the spring-boot application in a docker container. To do it, you can use the gradle task bootBuildImage
running the command:
./gradlew bootBuildImage
You can customize this task by adding a code block to the 'build.gradle.kts' file:
tasks.named<BootBuildImage>("bootBuildImage") {
imageName = "logging_example_app"
environment.apply {
put("BP_JVM_VERSION","17")
put("spring.profiles.active","k8s")
}
}
- Run the following commands:
docker-compose up
- Wait for all the containers to be ready and running
- Make a GET request to
http://localhost:8080/log
- Open your browser and go to
http://localhost:5601
and follow the steps in the last part of my article Logging aggregation system to see the logs in Kibana
To compile the project and run all the tests execute:
./gradlew build