1

How can the Serilog Exceptionless Sink be used with .NET Core 1.1?

The Serilog.Sinks.Exceptionless README isn't clear and doesn't work for .NET Core 1.1 where I have put the configuration in the appsettings.json file.

{
  "Serilog": {
    "Using": ["Serilog.Sinks.Literate"],
    "MinimumLevel": ["Debug"],
    "WriteTo": [{
      "Name": "LiterateConsole"
    }],
    "Enrich": ["FromLogContext"],
    "Properties": {
      "Application": "MyAppServer"
    }
  }
}

Program.cs

public class Program
{
    public static void Main(string[] args)
    {
        Log.Logger = new LoggerConfiguration()
            .ReadFrom.Configuration(config)
            .CreateLogger();
    }
}

I obviously need to set up the API key somewhere, too.

Can anyone provide a clear description of how this can be configured, please?

Boggin
  • 3,251
  • 3
  • 33
  • 48

2 Answers2

2

In JSON you can add additional sinks to the "WriteTo" list and add arguments like apiKey in the "Args" block:

{
  "Serilog": {
    "Using": ["Serilog.Sinks.Literate"],
    "MinimumLevel": ["Debug"],
    "WriteTo": [{
      "Name": "LiterateConsole"
    }, {
      "Name": "Exceptionless",
      "Args": { apiKey: "12345" }
    }],
    "Enrich": ["FromLogContext"],
    "Properties": {
      "Application": "MyAppServer"
    }
  }
}
Nicholas Blumhardt
  • 30,271
  • 4
  • 90
  • 101
1

I think it's

Log.Logger = new LoggerConfiguration()
    .WriteTo.Exceptionless(
        apiKey: "yourApiKey", 
        additionalOperation: b => b.AddTags("ASP.NET Core Example Logger"))
    .CreateLogger();
Boggin
  • 3,251
  • 3
  • 33
  • 48
Blake Niemyjski
  • 3,432
  • 3
  • 25
  • 41