Added serilog enricher

This commit is contained in:
Max
2024-06-16 21:08:26 +02:00
parent c1d18d5b47
commit 03daea46e7
3 changed files with 58 additions and 15 deletions

View File

@@ -0,0 +1,27 @@
using Serilog;
namespace DotBased.Logging.Serilog;
public static class BasedSerilog
{
/// <summary>
/// Default output template with the extra properties that can be used for serilog sinks.
/// </summary>
public const string OutputTemplate = "[{Timestamp:HH:mm:ss} - {Caller}->{Assembly}] | {Level:u3}] {Message:lj}{NewLine}{Exception}";
public static LoggerConfiguration UseBasedExtension(this LoggerConfiguration loggerConfiguration)
{
loggerConfiguration.Enrich.FromLogContext().Enrich.With(new BasedSerilogEnricher());
return loggerConfiguration;
}
/// <summary>
/// The extra properties this implementation adds to serilog
/// </summary>
public static class ExtraProperties
{
public const string AssemblyProp = "Assembly";
public const string SourceProp = "Source";
public const string CallerProp = "Caller";
}
}