Taming Ruby on Rails Logging with Lograge and Mezmo

4 MIN READ
MIN READ

LogDNA is now Mezmo but the product you know and live is here to stay

Ruby on Rails is a powerful and intuitive framework for building web applications. With its low barrier to entry, getting started is fast—but as applications grow in complexity, maintaining clear, actionable logs becomes essential for full stack monitoring.

Rails was originally designed when applications lived on a single server. Every interaction—loading a page, submitting a form—generates multiple verbose log entries, often across several lines, making it difficult to track a single user’s request or pinpoint failures.

Here’s a typical log sample for one simple action:

Started GET "/" for 127.0.0.1 at 2021-07-10 09:42:10 +0700 Processing by HomeController#index as HTML Rendered text template within layouts/application (0.0ms) Rendered layouts/_assets.html.erb (2.0ms) Rendered layouts/_top.html.erb (2.6ms) Rendered layouts/_about.html.erb (0.3ms) Completed 200 OK in 79ms (Views: 78.8ms | ActiveRecord: 0.0ms)

While manageable for small applications, this log fragmentation becomes problematic at scale, especially in containerized and serverless environments. Add in distributed systems, and parsing these scattered lines manually becomes nearly impossible.

That’s where Lograge enters the picture, bringing structure and clarity for teams managing complex telemetry pipelines.

In response to Rails' noisy logging, Mathias Meyer developed Lograge—a tool built to streamline Rails logs into structured, machine-parseable, single-line outputs. The result? Logs that are compact and highly usable in any telemetry pipeline.

Here’s what the example log looks like after applying Lograge:

{"method":"GET", "format:"html", "path":"/ controller=HomeController", "action":"home#index", "status":200, "duration":79, "view":78.8, "db":7.4}

This structure helps platforms like Mezmo ingest logs cleanly for APM logs, visualization, and correlation with traces and metrics, enabling deep application insight.

With structured logs enriched like this, Mezmo users benefit from enhanced traceability and the ability to feed detailed APM logs into dashboards and alerts.

# config/environments/development.rb Rails.application.configure do config.lograge.enabled = true config.lograge.custom_options = lambda do |event| { application: Rails.application.class.parent_name, host: event.payload[:host], rails_env: Rails.env, process_id: Process.pid, request_id: event.payload[:headers]['action_dispatch.request_id'], request_time: Time.now, remote_ip: event.payload[:remote_ip], ip: event.payload[:ip], x_forwarded_for: event.payload[:x_forwarded_for], params: event.payload[:params].except(*exceptions).to_json, exception: event.payload[:exception]&.first, exception_message: "#{event.payload[:exception]&.last}", exception_backtrace: event.payload[:exception_object]&.backtrace&.join(",") }.compact end end

To get the additional custom variables in the event payload you must add them to your controller. For instance, we could do something like

# app/controllers/application_controller.rb class ApplicationController < ActionController::Base def append_info_to_payload(payload) super payload[:host] = request.host paylod[:x_forwarded_for] = request.env['HTTP_X_FORWARDED_FOR'] end end

Since Meyer designed Lograge to integrate naturally with Ruby's built-in logging, we can use Mezmo's own Ruby/Rails logger to ingest logs from your application. In two short steps, you can have your entire application sending logs to Mezmo.

Step One: Include the logdna gem

gem 'logdna'

Step Two: Configure the Rails logger to use Mezmo with JSON-formatted Lograge

Rails.application.configure do config.lograge.enabled = true config.lograge.formatter = Lograge::Formatters::Json.new config.logger = Logdna::Ruby.new(YOUR_API_KEY, OPTIONS) end

And with that, your logs are both concise and aggregated, allowing you to monitor and troubleshoot your Rails app faster.

Pro Tip

Mezmo displays the message field as the human-readable headline of any log entry, making it easy to scan logs in the viewer. All other fields remain fully searchable and usable for filtering, alerting, and dashboarding.

Want to see this in action? Check out our GitHub guide to building a Rails decoder app with Lograge + Mezmo or contact one of our logging experts.

Join the Mezmo community, explore our docs, and level up your full stack monitoring today.

Table of Contents

    Share Article

    RSS Feed

    Next blog post
    You're viewing our latest blog post.
    Previous blog post
    You're viewing our oldest blog post.
    Mezmo’s AI-powered Site Reliability Engineering (SRE) agent for Root Cause Analysis (RCA)
    What is Active Telemetry
    Launching an agentic SRE for root cause analysis
    Paving the way for a new era: Mezmo's Active Telemetry
    The Answer to SRE Agent Failures: Context Engineering
    Empowering an MCP server with a telemetry pipeline
    The Debugging Bottleneck: A Manual Log-Sifting Expedition
    The Smartest Member of Your Developer Ecosystem: Introducing the Mezmo MCP Server
    Your New AI Assistant for a Smarter Workflow
    The Observability Problem Isn't Data Volume Anymore—It's Context
    Beyond the Pipeline: Data Isn't Oil, It's Power.
    The Platform Engineer's Playbook: Mastering OpenTelemetry & Compliance with Mezmo and Dynatrace
    From Alert to Answer in Seconds: Accelerating Incident Response in Dynatrace
    Taming Your Dynatrace Bill: How to Cut Observability Costs, Not Visibility
    Architecting for Value: A Playbook for Sustainable Observability
    How to Cut Observability Costs with Synthetic Monitoring and Responsive Pipelines
    Unlock Deeper Insights: Introducing GitLab Event Integration with Mezmo
    Introducing the New Mezmo Product Homepage
    The Inconvenient Truth About AI Ethics in Observability
    Observability's Moneyball Moment: How AI Is Changing the Game (Not Ending It)
    Do you Grok It?
    Top Five Reasons Telemetry Pipelines Should Be on Every Engineer’s Radar
    Is It a Cup or a Pot? Helping You Pinpoint the Problem—and Sleep Through the Night
    Smarter Telemetry Pipelines: The Key to Cutting Datadog Costs and Observability Chaos
    Why Datadog Falls Short for Log Management and What to Do Instead
    Telemetry for Modern Apps: Reducing MTTR with Smarter Signals
    Transforming Observability: Simpler, Smarter, and More Affordable Data Control
    Datadog: The Good, The Bad, The Costly
    Mezmo Recognized with 25 G2 Awards for Spring 2025
    Reducing Telemetry Toil with Rapid Pipelining
    Cut Costs, Not Insights:   A Practical Guide to Telemetry Data Optimization
    Webinar Recap: Telemetry Pipeline 101
    Petabyte Scale, Gigabyte Costs: Mezmo’s Evolution from ElasticSearch to Quickwit
    2024 Recap - Highlights of Mezmo’s product enhancements
    My Favorite Observability and DevOps Articles of 2024
    AWS re:Invent ‘24: Generative AI Observability, Platform Engineering, and 99.9995% Availability
    From Gartner IOCS 2024 Conference: AI, Observability Data, and Telemetry Pipelines
    Our team’s learnings from Kubecon: Use Exemplars, Configuring OTel, and OTTL cookbook
    How Mezmo Uses a Telemetry Pipeline to Handle Metrics, Part II
    Webinar Recap: 2024 DORA Report: Accelerate State of DevOps
    Kubecon ‘24 recap: Patent Trolls, OTel Lessons at Scale, and Principle Platform Abstractions
    Announcing Mezmo Flow: Build a Telemetry Pipeline in 15 minutes
    Key Takeaways from the 2024 DORA Report
    Webinar Recap | Telemetry Data Management: Tales from the Trenches
    What are SLOs/SLIs/SLAs?
    Webinar Recap | Next Gen Log Management: Maximize Log Value with Telemetry Pipelines
    Creating In-Stream Alerts for Telemetry Data
    Creating Re-Usable Components for Telemetry Pipelines
    Optimizing Data for Service Management Objective Monitoring
    More Value From Your Logs: Next Generation Log Management from Mezmo
    A Day in the Life of a Mezmo SRE
    Webinar Recap: Applying a Data Engineering Approach to Telemetry Data
    Dogfooding at Mezmo: How we used telemetry pipeline to reduce data volume
    Unlocking Business Insights with Telemetry Pipelines
    Why Your Telemetry (Observability) Pipelines Need to be Responsive
    How Data Profiling Can Reduce Burnout
    Data Optimization Technique: Route Data to Specialized Processing Chains
    Data Privacy Takeaways from Gartner Security & Risk Summit
    Mastering Telemetry Pipelines: Driving Compliance and Data Optimization
    A Recap of Gartner Security and Risk Summit: GenAI, Augmented Cybersecurity, Burnout
    Why Telemetry Pipelines Should Be A Part Of Your Compliance Strategy
    Pipeline Module: Event to Metric
    Telemetry Data Compliance Module
    OpenTelemetry: The Key To Unified Telemetry Data
    Data optimization technique: convert events to metrics
    What’s New With Mezmo: In-stream Alerting
    How Mezmo Used Telemetry Pipeline to Handle Metrics
    Webinar Recap: Mastering Telemetry Pipelines - A DevOps Lifecycle Approach to Data Management
    Open-source Telemetry Pipelines: An Overview
    SRECon Recap: Product Reliability, Burn Out, and more
    Webinar Recap: How to Manage Telemetry Data with Confidence
    Webinar Recap: Myths and Realities in Telemetry Data Handling
    Using Vector to Build a Telemetry Pipeline Solution
    Managing Telemetry Data Overflow in Kubernetes with Resource Quotas and Limits
    How To Optimize Telemetry Pipelines For Better Observability and Security
    Gartner IOCS Conference Recap: Monitoring and Observing Environments with Telemetry Pipelines
    AWS re:Invent 2023 highlights: Observability at Stripe, Capital One, and McDonald’s
    Webinar Recap: Best Practices for Observability Pipelines
    Introducing Responsive Pipelines from Mezmo
    My First KubeCon - Tales of the K8’s community, DE&I, sustainability, and OTel
    Modernize Telemetry Pipeline Management with Mezmo Pipeline as Code
    How To Profile and Optimize Telemetry Data: A Deep Dive
    Kubernetes Telemetry Data Optimization in Five Steps with Mezmo
    Introducing Mezmo Edge: A Secure Approach To Telemetry Data
    Understand Kubernetes Telemetry Data Immediately With Mezmo’s Welcome Pipeline
    Unearthing Gold: Deriving Metrics from Logs with Mezmo Telemetry Pipeline
    Webinar Recap: The Single Pane of Glass Myth
    Empower Observability Engineers: Enhance Engineering With Mezmo
    Webinar Recap: How to Get More Out of Your Log Data
    Unraveling the Log Data Explosion: New Market Research Shows Trends and Challenges
    Webinar Recap: Unlocking the Full Value of Telemetry Data
    Data-Driven Decision Making: Leveraging Metrics and Logs-to-Metrics Processors
    How To Configure The Mezmo Telemetry Pipeline
    Supercharge Elasticsearch Observability With Telemetry Pipelines
    Enhancing Grafana Observability With Telemetry Pipelines
    Optimizing Your Splunk Experience with Telemetry Pipelines
    Webinar Recap: Unlocking Business Performance with Telemetry Data
    Enhancing Datadog Observability with Telemetry Pipelines
    Transforming Your Data With Telemetry Pipelines
    6 Steps to Implementing a Telemetry Pipeline