Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

##Log4j Spring Cloud Sample Application

This application uses Spring Boot and reads the logging configuration from the companion Spring Cloud Config Server project. The log4j2.xml file is located in the config-repo directory in that project.

This sample packages the application in a docker container that is packaged with rabbit-mq (to allow dynamic updates from Spring Cloud Config), fluent-bit (to test as a log forwarder), Apache Flume (to test as a log forwarder), and Apache Kafka also as a log forwarder. It also installs Socat, a proxy to allow access to the Docker REST API. ###Prerequisites Note: This guide assumes you already have docker installed. If you do not you may either use homebrew to install it or follow the instructions at

Like Log4j, the sample app uses the Maven toolchains plugin. The sample app may be built with Java 8 but is configured to run in a docker container with Java 11.

The KafkaAppender requires a Kafka instance to write to. On MacOS a Kafka instance can be created by

brew install kafka
zookeeper-server-start /usr/local/etc/kafka/ & kafka-server-start /usr/local/etc/kafka/

###Starting the Application

  • Start the companion rabbit-mq, fluent-bit and flume images ./docker/
  • Compile and start local application image ./docker/
  • The application exposes two endpoints.
    1. http://localhost:8080/sample/log?threads=1&count=100000 This endpoint will log up to 100,000 events using 1 or more threads.
    2. http://localhost:8080/sample/exception This endpoint generates an exception that can be used to verify whether multiline logging works with the chosen set of components.

###Viewing the logs

Accessing the log files varies depending on the appending being used. When logging to the console "docker logs" may be used. As configured, Flume will write to files in /var/log/flume, fluent-bit to the standard output of its container. Kafka output may be viewed using a tool like Kafka Tool.

You can’t perform that action at this time.