-
-
Notifications
You must be signed in to change notification settings - Fork 229
Open
Labels
Description
This line shows that a serilog log's properties are set as 'extra' for the event, but once I log an event and add properties, it is nowhere to be found.
This does not fit so much with the behavior in other sinks I have seen so far.
Is there a reason for this?
Perhaps a function in the style of ExtractBreadCrumbDataFromLogEvent below would be better?
class SentrySink : ILogEventSink
{
public void Emit(LogEvent logEvent)
{
Dictionary<string, string> breadcrumbData = ExtractBreadCrumbDataFromLogEvent(logEvent);
SentrySdk.AddBreadcrumb(
message: logEvent.RenderMessage(),
category: "Log",
type: "Default",
data: breadcrumbData,
level: MapLevel(logEvent.Level)
);
}
private static Dictionary<string, string> ExtractBreadCrumbDataFromLogEvent(LogEvent logEvent)
{
var breadcrumbData = new Dictionary<string, string>();
if (logEvent.Exception is not null)
breadcrumbData["Exception"] = logEvent.Exception.ToString().Trim('"');
foreach (var prop in logEvent.Properties)
breadcrumbData[prop.Key] = prop.Value.ToString().Trim('"');
return breadcrumbData;
}
private static BreadcrumbLevel MapLevel(LogEventLevel level) =>
level switch
{
LogEventLevel.Verbose => BreadcrumbLevel.Debug,
LogEventLevel.Debug => BreadcrumbLevel.Debug,
LogEventLevel.Information => BreadcrumbLevel.Info,
LogEventLevel.Warning => BreadcrumbLevel.Warning,
LogEventLevel.Error => BreadcrumbLevel.Error,
LogEventLevel.Fatal => BreadcrumbLevel.Critical,
_ => BreadcrumbLevel.Info
};
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Projects
Status
No status
Status
No status