Installation
Enable JSON structured logging for your application:
1. Add to your Gemfile
2. Bundle install
Monitoring and Dashboards
Structured JSON logs are easy to parse, so you can quickly set up metrics, alerts, and dashboards.
Features
Type-safe with Sorbet
LogStruct is fully type-checked with Sorbet. Your logs are guaranteed to have the correct structure and valid data.
Advanced Filtering and Scrubbing
Automatically redact sensitive information like emails, credit cards, passwords, IPs, and SSNs from your log output.
Integrates with Everything
Integrates with ActiveJob, ActionMailer, ActiveStorage, Lograge, Sidekiq, Carrierwave, and more to provide consistent structured logging. (Open a PR to add support for your favorite gem!)
Error Reporting
Smart and configurable error handling behaviors. Automatic error reporting integration with Sentry, Bugsnag, Rollbar, and Honeybadger.
Cloud-Ready
Compatible with AWS CloudWatch, Google Cloud Logging, and other cloud monitoring services that can filter and parse JSON log data. LogStruct provides Terraform types so your IaC config is always type-safe and up-to-date.
Tagged Logging
Add tags to your logs for better querying and aggregation. Perfect for tracking requests, background jobs, or custom workflows.
Project Status
Frequently Asked Questions
Is LogStruct free?
Yes, LogStruct is completely free and open source under the MIT license. Pull requests and contributions are welcome!
Why was LogStruct built?
DocSpring was originally using the lograge gem to format our request logs as JSON. We realized that we had a lot of other plain text logs that would be useful for CloudWatch metrics and dashboards. We wrote much of this code in our own app before deciding to extract it and release it as a gem. (It was also a great opportunity to learn more about Sorbet.)
What about other logging gems?
Several other gems provide structured logging for Rails apps, including Rails Semantic Logger, Lograge, Logstasher, and Logcraft. LogStruct focuses on powerful filtering and scrubbing, structured error handling, and type‑safety across integrations. See the comparison page for a detailed breakdown.