Skip to content

Instantly share code, notes, and snippets.

@electron0zero
Created June 30, 2020 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save electron0zero/83658f263212ea9a5515c80696b39db3 to your computer and use it in GitHub Desktop.
Save electron0zero/83658f263212ea9a5515c80696b39db3 to your computer and use it in GitHub Desktop.
Using Logstasher in Rails

Setting Logstasher for Rails

Logstasher's tagline is Awesome Logging for Rails !!, and it does what it says.

we have been using it in prod, and it's working fine.

Our logging setup is Logstasher -> Filebeat Sidecar -> Logstash -> Elasticsearch -> Kibana

  • Logstasher for json fomatted logs
  • Filebeat to ship the logs to ELK Stack

Setup and Config

  1. install gem by adding it in gemfile and bundle install
  2. edit rails env config file, for prod config/environments/production.rb

in configure block add follwing, and you will see logs in log/logstasher.log

  # Enable the logstasher logs for the current environment
  config.logstasher.enabled = true

  # This line is optional if you do not want to suppress app logs in your <environment>.log
  config.logstasher.suppress_app_log = false

  config.logstasher.log_controller_parameters = true

  # This line is optional, defaults to log/logstasher_<environment>.log
  config.logstasher.logger_path = 'log/logstasher.log'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment