2024-06-16 21:08:26 +02:00
|
|
|
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>
|
2024-11-17 22:51:54 +01:00
|
|
|
public const string OutputTemplate = "[{Timestamp:HH:mm:ss} {Level:u3} - {LoggerName}]{NewLine} {Message:lj}{NewLine}{Exception}";
|
2024-06-16 21:08:26 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
{
|
2024-11-17 22:51:54 +01:00
|
|
|
public const string LoggerName = "LoggerName";
|
2024-06-16 21:08:26 +02:00
|
|
|
public const string AssemblyProp = "Assembly";
|
2024-11-17 22:51:54 +01:00
|
|
|
public const string FullNameProp = "FullName";
|
|
|
|
public const string NamespaceProp = "Namespace";
|
2024-06-16 21:08:26 +02:00
|
|
|
public const string CallerProp = "Caller";
|
|
|
|
}
|
|
|
|
}
|