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:

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:

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

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.