Skip to content

Commit

Permalink
Added prefix as attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesmols committed May 11, 2023
1 parent 5b137aa commit 3d13603
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Serilog.Enrichers.CallerInfo/Enricher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
var method = frame?.MethodInfo.MethodBase;
var type = method?.DeclaringType;

if (!string.IsNullOrWhiteSpace(_prefix))
{
logEvent.AddPropertyIfAbsent(new LogEventProperty("Serilog.Enrichers.CallerInfo_Prefix", new ScalarValue(_prefix)));
}

if (type != null)
{
logEvent.AddPropertyIfAbsent(new LogEventProperty($"{_prefix}Method", new ScalarValue(method.Name)));
Expand Down

0 comments on commit 3d13603

Please sign in to comment.