Taking structured logging and elmah.io to the next level
We've supported a range of different logging frameworks for years. The more modern options support something called structured logging, which means that you can embed rich information inside a log message:
log.Information("Hello from {user}", "Ray Donovan");
When looking at the message logged to a file, you'll see the text Hello from Ray Donovan
, but when utilizing a structured logging endpoint like elmah.io or Elasticsearch, log messages can be searched by user
and a lot of other benefits.
Until now, properties inside log messages have gone into the Data tab on elmah.io. While the properties can be made searchable, a common request has been to be able to fill in field values on elmah.io like User
, URL
, and Hostname
. With the recent wave of new versions of our logging framework integrations, setting field values using structured logging is now possible using a simple syntax:
log.Info("{Quote} from {User}", "Hasta la vista, baby", "Arnold Schwarzenegger");
In the example, the User
field on the elmah.io UI will be populated with the value Arnold Schwarzenegger
. Both the Quote
and User
property will still be added to the Data tab, but searching and grouping by a user is now a piece of cake:
user.raw:"Arnold Schwarzenegger"
The new structured logging support is available in our integrations for Serilog, NLog and Microsoft.Extensions.Logging. Enjoy, and as always, please get in contact with feedback.
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