Lograge is one of the all-time great Rails gems and is one of those 3-4 gems like devise, timecop or rails_admin that a lot of us are quick to install on a new project.
So, lograge is great, but there are better alternatives in 2024. We'll examine two options: an excellent free choice called Rails Semantic Logger and one I've built for the Prefab platform.
First, let's take a quick look at what problem we're trying to solve. Here's the logging you get from Rails & Lograge out of the box at info level.
But, a single-line request summary is not the only interesting aspect of logging. What about tagged and struct logging? What about debug logging? How can these libraries help us figure out what's actually going on?
To exercise the other aspects of logging, here's the sample code we will run. It logs at all four levels and uses tagged and structlog to show how to add context to your logs.