Code Monkey home page Code Monkey logo

spring-boot-log4j-2-scaffolding's Introduction

spring-boot-log4j-2-scaffolding

keep growing logo

This project is a simple scaffolding for a Spring Boot application that uses Log4j 2 for logging and Elastic Stack for processing log entries.

To learn how to set up a project like this one, check out the following posts:

Getting Started

To clone the repository, run in the command line:

$ git clone https://github.com/little-pinecone/spring-boot-log4j-2-scaffolding.git

You can build the application with:

$ mvn clean install

Spring security

The application uses Spring Boot security starter. The default credentials are specified in the application.properties file:

  • Useranme test
  • Password test

Monitoring Spring Boot with Actuator

After starting the Spring Boot app, you have to sign in:

login form

Now you can browse the enabled and exposed Actuator endpoints: info, health, metrics.

Run the Spring Boot app, Elastic Stack, Prometheus and Grafana

  • Run this application to make sure that the all.log file is created and not empty (more than one line is required).
  • Run the $ docker-compose up -d command in the project directory. The following services should be started:
IMAGE                                     PORTS                                            NAMES
elasticsearch:7.7.0                  0.0.0.0:9200->9200/tcp, 9300/tcp                 springbootelasticstack_elasticsearch_1
logstash:7.7.0                       0.0.0.0:5044->5044/tcp, 0.0.0.0:9600->9600/tcp   springbootelasticstack_logstash_1
kibana:7.7.0                         0.0.0.0:5601->5601/tcp                           springbootelasticstack_kibana_1
springbootelasticstack_filebeat                                                       springbootelasticstack_filebeat_1
springbootelasticstack_metricbeat                                                     springbootelasticstack_metricbeat_1
elastichq/elasticsearch-hq:latest    0.0.0.0:5000->5000/tcp                           springbootelasticstack_elastichq_1
prom/prometheus                      0.0.0.0:9090->9090/tcp                           springbootelasticstack_prometheus_1
grafana/grafana:7.1.3                0.0.0.0:3000->3000/tcp                           springbootelasticstack_grafana_1
springbootelasticstack_app           0.0.0.0:8080->8080/tcp                           springbootelasticstack_app_1
  • Visit http://localhost:5000/#!/ to use ElastiHQ interface to verify the content send to Elasticsearch (run Query for the spring-boot-app-logs-YYYY.MM.dd index):

elastichq-screenshot

  • Visit http://localhost:5601/ to log in to Kibana:

kibana-login-screenshot

  • Use the default username: elastic and password: test.
  • Create index defined in the logstash.conf file and browse logs accumulated in the logs/all.log file (the file is automatically created on the application startup):

kibana-discover-screenshot

  • Visit http://localhost:5601/app/monitoring to check out clusters monitoring:

stack-monitoring-screenshot

Standalone cluster shows metrics for Filebeat, docker-cluster displays metrics for Elasticsearch, Kibana and Logstash:

docker-cluster-screenshot

You can also monitor the application state using Grafana:

grafana-dashboard-screenshot

Overview and technical features

  • Log4j 2 is used for logs processing.
  • The application uses the root logger and sends log entries to RollingFile and Console appenders (when you run the app, the logs directory will be created automatically).
  • After log entries had been processed by Filebeat and Logstash, they are send to ElasticSearch.
  • You can browse logs in Kibana.
  • You can browse Elastic Stack metrics in a Kibana dashboard.
  • You can monitor the Spring Boot app using Actuator endpoints.
  • You can monitor the Spring Boot app using the Prometheus or Grafana dashboards.
  • Project documentation

Built With

License

This project is licensed under the Unlicense - see the license details.

spring-boot-log4j-2-scaffolding's People

Contributors

little-pinecone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.