A serilog sink that sends task logs to Netflix Conductor. Don't use this sink as your only sink.
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();
{
"Serilog": {
"WriteTo": [
{
"Name": "ConductorTaskLog",
"Args": {
"conductorUrl": "http://conductor:8080/api/"
}
}
],
"Enrich": [
"FromLogContext"
]
}
}
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();
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");
}