Allows exception message without a stack trace to be written to the console, while full exception details are still written to file sinks.pull/201/head
parent
684128968c
commit
64306db2dc
@ -0,0 +1,18 @@
|
||||
using Serilog.Core;
|
||||
using Serilog.Events;
|
||||
|
||||
namespace Recyclarr.Common.Serilog;
|
||||
|
||||
public class ExceptionMessageEnricher : ILogEventEnricher
|
||||
{
|
||||
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
|
||||
{
|
||||
if (logEvent.Exception is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty(
|
||||
"ExceptionMessage", logEvent.Exception.Message));
|
||||
}
|
||||
}
|
Loading…
Reference in new issue