Structured logging vNext

We have had support for structured logging on elmah.io ever since we released the first integrations with logging frameworks like Serilog and NLog. With today's release, we have made a range of improvements which qualify for an announcement post.

When logging messages to elmah.io from a structured logging framework, the procedure has always been well-defined. The formatted log message is saved in the message field, and structured properties go into the Data tab. With a little naming magic, structured logging properties are even searchable. In the past, we didn't store the original log message (like {user} says hello), only the formatted message and the embedded properties. Today, we've released prereleases of the integrations with Serilog, NLog and Microsoft.Extensions.Logging that store the templated message as well.

The screenshots in this post are based on the following log statements using the Serilog sink, but the approach is similar for NLog, and Microsoft.Extensions.Logging:

Log.Information("{user} says hello", "Richard");
Log.Information("{user} says hello", "Jared");

So, why is this a big change you might think? The most obvious thing is to support better search through the elmah.io UI:

Structured search in elmah.io

In the example above, I search for all log messages using the template string and not the formatted message. The query will find both "Richard" says hello, and "Jared" says hello. In the past, searches like these would rely on wildcards. The screenshot shows a full-text query, but the messageTemplate field is accessible using filters as well:

Add filter

Another benefit is with rules. Like searches, you can now create advanced rules based on groups of log messages:

Structured rule

Today's launch is just the first preview of the improved support for structured logging on elmah.io. We have a few features planned already and lots of others on the drawing board. Something that we will look into next is optimizing our grouping algorithm to use templates over formatted messages.

To get access to template messages inside elmah.io, you need to upgrade to Serilog.Sinks.ElmahIo 3.4.0-pre, Elmah.Io.NLog 3.5.61-pre, or Elmah.Io.Extensions.Logging 3.5.46-pre.

elmah.io: Error logging and Uptime Monitoring for your web apps

This blog post is brought to you by elmah.io. elmah.io is error logging, uptime monitoring, deployment tracking, and service heartbeats for your .NET and JavaScript applications. Stop relying on your users to notify you when something is wrong or dig through hundreds of megabytes of log files spread across servers. With elmah.io, we store all of your log messages, notify you through popular channels like email, Slack, and Microsoft Teams, and help you fix errors fast.

See how we can help you monitor your website for crashes Monitor your website