# LogStruct

> Zero-config, type-safe JSON logging for Ruby on Rails apps

Source: https://talira.ai/catalog/logstruct-ngqw8tgp
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Verified: its makers verified it through docspring.com, since 21 Nov 2026
- Types: Library
- Categories: [observability / logging](https://talira.ai/categories/observability/logging), [languages / ruby / rails](https://talira.ai/categories/languages/ruby/rails)
- Licence: MIT
- Pricing: Free and open source
- Free tier: yes
- Self-hostable: yes
- Backed by: [DocSpring](https://talira.ai/orgs/docspring.md)

LogStruct is a Ruby gem that makes a Rails app (Rails 7.1+, Ruby 3.3+) write one JSON line per log entry to STDOUT in production: requests, jobs, mail, errors, security events and the app's own logs. It replaces Rails' loggers with a SemanticLogger logger, turns on [Lograge](https://talira.ai/catalog/lograge-7c56p58z.md) for request lines, and adds structured lines for [Sidekiq](https://talira.ai/catalog/sidekiq-yt9yy9ky.md), [GoodJob](https://talira.ai/catalog/goodjob-1jjxahdr.md), ActiveJob, ActionMailer, [Puma](https://talira.ai/catalog/puma-qdbe2rmt.md), ActiveStorage, [Shrine](https://talira.ai/catalog/shrine-178m6tsb.md), CarrierWave and more. Values under sensitive keys are filtered, and emails (as a keyed hash), card numbers, phone numbers, SSNs and credentials are scrubbed from strings before a line is written. Every built-in line is a [Sorbet](https://talira.ai/catalog/sorbet-7qt3f670.md)-typed struct, and a separate [Terraform](https://talira.ai/catalog/terraform-zdejdqmx.md) provider checks the source and event names in CloudWatch metric filters at plan time.

## Links

- Website: https://logstruct.com
- GitHub: https://github.com/DocSpring/logstruct
- Docs: https://logstruct.com/docs

## Problems it solves

- my Rails production logs are multi-line text that CloudWatch can't turn into metrics
- Lograge only covers request lines, and Sidekiq jobs, mailers and errors are still plain text
- passwords and API tokens from request params and job arguments are ending up in our logs
- scrub email addresses and card numbers out of log messages but still follow one user through the logs
- I need logging that satisfies SOC 2 requirements without writing it all myself
- one JSON line per request with the request ID, duration, status and client IP
- every log line during a request should carry the same request id so I can trace it
- an unhandled exception in Rails prints a huge block of text instead of one searchable entry
- huge params hashes and backtraces are bloating our log ingestion bill
- build Datadog or Grafana dashboards from Rails logs without regex parsing
- my CloudWatch metric filters silently stop matching when someone renames a log event
- decide per kind of error whether it's raised in development and reported to Sentry in production
- log to stdout only in containers so there's no log file filling up the disk

## Features

- JSON lines to STDOUT in production
- switches on for recognized server and worker processes only
- filtering of values under sensitive key names
- scrubbing of emails (keyed hash), card numbers, phone numbers, SSNs, URL passwords and bearer credentials
- size limits for hashes, arrays, backtraces and strings
- per-error-type handling modes (raise, log, report)
- Sorbet-typed log structs and custom typed log classes
- request ID and tags on every line
- Terraform provider that checks CloudWatch metric filters at plan time

## Trust

Overall: 0.49 out of 1.
Signals: maintenance 1.00, adoption 0.30, momentum 0.12, community 0.19, backing 0.30, extensibility 0.00.

- last commit 9 days ago
- 195 commits in the last 90 days
- 31 GitHub stars
- 2 contributors
- backed by DocSpring

Warnings:

- one or two maintainers (bus factor)

## Alternatives

- [Lograge](https://talira.ai/catalog/lograge-7c56p58z.md): Taming Rails' default request logging
