项目作者: TwoUnderscorez

项目描述 :
Serilog sink for Netflix Conductor
高级语言: C#
项目地址: git://github.com/TwoUnderscorez/serilog-sinks-conductor-task-log.git
创建时间: 2020-08-21T20:28:32Z
项目社区:https://github.com/TwoUnderscorez/serilog-sinks-conductor-task-log

开源协议:BSD 3-Clause "New" or "Revised" License

下载


Serilog.Sinks.ConductorTaskLog " class="reference-link"> 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)

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

In appsettings.json

  1. {
  2. "Serilog": {
  3. "WriteTo": [
  4. {
  5. "Name": "ConductorTaskLog",
  6. "Args": {
  7. "conductorUrl": "http://conductor:8080/api/"
  8. }
  9. }
  10. ],
  11. "Enrich": [
  12. "FromLogContext"
  13. ]
  14. }
  15. }

Using

With conductor-dotnet-client

Add the using

  1. using Serilog.Sinks.ConductorTaskLog.Extensions;

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

  1. using var _ = task.LogScope();

With something else

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

  1. using Serilog.Sinks.ConductorTaskLog;
  2. using var _ = TaskLog.LogScope("taskId");

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

  1. Log.Information("Not logging to Netflix Conductor");
  2. using (TaskLog.LogScope("taskId"))
  3. {
  4. Log.Information("Log sent to Netflix Conductor");
  5. }