Initialize CBDD solution and add a .NET-focused gitignore for generated artifacts.
This commit is contained in:
30
tests/CBDD.Tests.Benchmark/Logging.cs
Normal file
30
tests/CBDD.Tests.Benchmark/Logging.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Serilog;
|
||||
|
||||
namespace ZB.MOM.WW.CBDD.Tests.Benchmark;
|
||||
|
||||
internal static class Logging
|
||||
{
|
||||
private static readonly Lazy<ILoggerFactory> LoggerFactoryInstance = new(CreateFactory);
|
||||
|
||||
public static ILoggerFactory LoggerFactory => LoggerFactoryInstance.Value;
|
||||
|
||||
public static Microsoft.Extensions.Logging.ILogger CreateLogger<T>()
|
||||
{
|
||||
return LoggerFactory.CreateLogger<T>();
|
||||
}
|
||||
|
||||
private static ILoggerFactory CreateFactory()
|
||||
{
|
||||
var serilogLogger = new LoggerConfiguration()
|
||||
.Enrich.FromLogContext()
|
||||
.WriteTo.Console()
|
||||
.CreateLogger();
|
||||
|
||||
return Microsoft.Extensions.Logging.LoggerFactory.Create(builder =>
|
||||
{
|
||||
builder.ClearProviders();
|
||||
builder.AddSerilog(serilogLogger, dispose: true);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user