How to send push notifications with Serilog to your mobile device

How to send push notifications with Serilog to your mobile device

Serilog is an open-source logging library for .NET applications that provides a flexible and structured way to capture and store log data. It offers a variety of sinks for storing log data, including console, file, database, and cloud-based services. With Serilog, developers can easily capture relevant information about the state of their application, including contextual information like user information, request information, and more.

When it comes to error management and troubleshooting, Serilog can be a valuable tool. By capturing exceptions and errors in a structured way, developers can gain greater visibility into the root causes of issues in their applications. They can then use this information to identify and resolve issues more quickly and efficiently.

Pushing exceptions and errors to a service like LogHive can further enhance the benefits of using Serilog for error management. With LogHive, developers can receive real-time notifications when errors occur, enabling them to respond quickly and address issues before they impact users.

How to do

This C# library is a sink for the Serilog Logging Framework. With this extension, all log events that occur are automatically transmitted to the event and log service LogHive:


To ensure that the Serilog extension is found, you should include the namespace Serilog.Sinks.LogHive in your Usings section.

"Serilog": {
    "Using": [
    "MinimumLevel": {
      "Default": "Warning"
    "WriteTo": [
        "Name": "Console"
        "Name": "LogHiveSink",
        "Args": {
          "ApiKey": "your-api-key",
          "ProjectName": "yourprojectname",
          "GroupName": "yourgroupname",
          "ParseMessageTemplateForEventName": false,
          "RestrictedToMinimumLevel": "Error",
          "MinimumPushNotificationLevel": "Error"

You can receive your API-Key here: API-Key.

You can also instantiate logging directly through the code:

var log = new LoggerConfiguration()
                .WriteTo.LogHiveSink("your-api-key", "yourprojectname", "yourgroupname",
                LogEventLevel.Information, LogEventLevel.Information)

var position = new { Latitude = 25, Longitude = 134 };
var elapsedMs = 34;

log.Information("Processed {@Position} in {Elapsed:000} ms.", position, elapsedMs);

That’s it. Using the Appsettings or instantiation with the passing of parameters, all logs from a configurable log level are sent to LogHive.

Example Exception with Full StackTrace for Event Logging with LogHive
Example Exception with Full StackTrace

The source code is available under:

Latest Posts