Where do you want to collect your Ruby logs from?
Collect logs from your Rails application, including your Sidekiq jobs. This integration also supports Structured Events in Rails 8.1 or higher for rich, queryable event logging.
Install Better Stack Rails Gem:
Set up Better Stack Rails Gem in config/application.rb:
Use Rails logger as usual:
You should see your logs in Better Stack Logs β Live tail.
Check out the Ruby on Rails dashboard.
Rails version 5.0 or higher is required.
Ruby version 2.5 or higher is required.
Collect logs from any Rack-based framework such as Sinatra, Hanami, Padrino, or Roda.
Install Better Stack Rack Gem:
Set up Better Stack Rack Gem in your config.ru:
Use the instantiated logger instance to send logs to Better Stack:
You should see your logs in Better Stack Logs β Live tail.
Rack version 1.2 or higher is required.
Ruby version 2.3 or higher is required.
Collect logs from your Ruby code.
Install Better Stack Gem:
Set up Better Stack Ruby client:
Use Ruby logger as usual:
You should see your logs in Better Stack β Live tail.
Ruby version 2.3.0 or higher is required.
Please let us know at hello@betterstack.com.
We're happy to help! π
You can take a look at example projects on Github:
Interested in learning more about log levels in Rails?
Check out our Intro guide to Ruby on Rails logging.
Add custom data to multiple log lines using with block:
In Rails or Rack, you can filter sensitive parameters and HTTP headers:
You can prevent logger from sending certain logs to Better Stack:
See Logtail::LogEntry for available attributes of the block parameter.
Starting with Rails 8.1, you can use the new Structured Events system to send structured data to Better Stack. The logtail-rails gem automatically subscribes to these events and logs them as structured log entries in case you've used Logtail::Logger.create_default_logger to initialize.
This is particularly useful for tracking key business events or application-specific actions with rich, queryable data, without having to format them into a log message.
When you use Rails.event.notify, the logtail-rails gem captures the event name, payload, context, tags, and source location, and sends it all as a structured log to Better Stack.
We use cookies to authenticate users, improve the product user experience, and for personalized ads. Learn more.