LogHive provides a simple REST API that you can use to push events and errors. Here is an example code for C#:


You're lucky! There is already an SDK available for C# that you can easily download via NuGet. With this, you only need a maximum of two lines of code to push an event to LogHive.

var logger = new LogHiveApi("your-api-key");

// push event
var notification = false;
var responseEvent = await logger.AddEventAsync("yourprojectname", "yourgroupname", "your-event-name", "descripton", notification);

// push insight
var responseInsight = await logger.AddInsightAsync("yourprojectname", "yourinsightname", 100);

// online offline state
await logger.SetSystemOnlineAsync("yourprojectname", "yoursystemname");
await logger.SetSystemOfflineAsync("yourprojectname", "yoursystemname");

The SDK internally uses HttpClient, so you only need to instantiate LogHiveApi once.

NuGet Link: https://www.nuget.org/packages/LogHive

GitHub Link: https://github.com/loghive

Serilog Sink

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.

NuGet Link: https://www.nuget.org/packages/Serilog.Sinks.LogHive/

GitHub Link: https://github.com/loghive/serilog-sinks-loghive


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

  • ApiKey: your personal api key

  • RestrictedToMinimumLevel: minimum Log Level to push the event to LogHive

  • MinimumPushNotificationLevel: minimum Log Level to push a notification

  • ParseMessageTemplateForEventName: parse message template to full string without property placeholders (default: false)

"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 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);

Last updated