Skip to content

Instantly share code, notes, and snippets.

@pavankjadda
Created February 6, 2019 05:42
Show Gist options
  • Save pavankjadda/a913ddcd841a7918afd0ebb591abd1fa to your computer and use it in GitHub Desktop.
Save pavankjadda/a913ddcd841a7918afd0ebb591abd1fa to your computer and use it in GitHub Desktop.
Setup ELK Stack logging with Spring Boot
  1. Download Elastic Search and unzip it
  2. Start Elastic search with the following command and go to URL http://localhost:9200
$ bin/elasticsearch
  1. Download LogStash and unzip it
  2. Create logstash-elk.conf file on logstash home directory with the following content and change the log file location and index name based on your settings
input {
    file {
        path => "/Users/johnd/ELK-Stack/logback/*.log"
        codec => "json"
        type => "logback"
    }
}
 
output {
    if [type]=="logback" {
         elasticsearch {
             hosts => [ "localhost:9200" ]
             index => "logstash"
        }
    }
}

  1. Start the logstash with the command
$ bin/logstash -f logstash-elk.conf
  1. Download Kibana then unzip it, run it with the following command
bin/kibana
  1. Go to http://localhost:5601 to see Kibana UI
  2. Go to Spring Boot application.yml file and add logging file location oproperties
# Logging
logging:
  file: /Users/johnd/ELK-Stack/logback/springsecuritydata.log
  1. Restart the Spring Boot application to capture logs in the newly created file springsecuritydata.log
  2. Go to Kibana UI -> Management -> Create Index pattern -> Type index name (You should see the index name below)
  3. Go to Kibana UI -> Dashboard to see Spring Boot log data, modify the filter to see data from past
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment