Skip to content

Instantly share code, notes, and snippets.

@nblumhardt
Created February 27, 2019 05:33
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nblumhardt/418ec93bbac79704ac3f8ed2684f70cb to your computer and use it in GitHub Desktop.
Save nblumhardt/418ec93bbac79704ac3f8ed2684f70cb to your computer and use it in GitHub Desktop.
using System;
using Serilog.Core;
using Serilog.Events;
// .Enrich.With(new OperationIdEnricher())
class OperationIdEnricher : ILogEventEnricher
{
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
{
if (logEvent.Properties.TryGetValue("RequestId", out var requestId))
logEvent.AddPropertyIfAbsent(new LogEventProperty("operationId", requestId));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment