Skip to content

TwoUnderscorez/serilog-sinks-conductor-task-log

Repository files navigation

Serilog.Sinks.ConductorTaskLog Build Status Deployment status NuGet Version

A serilog sink that sends task logs to Netflix Conductor. Don't use this sink as your only sink.

Showcase

Showcase

Getting started

Configuring

In code

Add the sink to your logger configuration (typically in Program.cs)

Log.Logger = new LoggerConfiguration()
      ...
      .WriteTo.ConductorTaskLog("http://conductor:8080/api/") // <-- Add the sink
      .Enrich.FromLogContext() // <-- Also add this enricher
      .CreateLogger();

In appsettings.json

{
   "Serilog": {
      "WriteTo": [
         {
            "Name": "ConductorTaskLog",
            "Args": {
               "conductorUrl": "http://conductor:8080/api/"
            }
         }
      ],
      "Enrich": [
         "FromLogContext"
      ]
   }
}

Using

Add the using

using Serilog.Sinks.ConductorTaskLog.Extensions;

The add this line at the start of your Execute method to let the sink know the taskId.

using var _ = task.LogScope();

With something else

Add this line at the start of any method to log all events from that method

using Serilog.Sinks.ConductorTaskLog;

using var _ = TaskLog.LogScope("taskId");

or like so to only log a few lines to the conductor

Log.Information("Not logging to Netflix Conductor");
using (TaskLog.LogScope("taskId"))
{
      Log.Information("Log sent to Netflix Conductor");
}