Fix logging in SingleFile setup
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using System.Runtime;
|
using System.Runtime;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using Serilog.Exceptions;
|
using Serilog.Exceptions;
|
||||||
|
using Serilog.Settings.Configuration;
|
||||||
using SPTarkov.Common.Semver;
|
using SPTarkov.Common.Semver;
|
||||||
using SPTarkov.Common.Semver.Implementations;
|
using SPTarkov.Common.Semver.Implementations;
|
||||||
using SPTarkov.DI;
|
using SPTarkov.DI;
|
||||||
@@ -94,25 +95,22 @@ public static class Program
|
|||||||
{
|
{
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
builder.Logging.ClearProviders();
|
builder.Logging.ClearProviders();
|
||||||
|
builder.Configuration.SetBasePath(Directory.GetCurrentDirectory());
|
||||||
|
|
||||||
if (ProgramStatics.DEBUG())
|
if (ProgramStatics.DEBUG())
|
||||||
{
|
{
|
||||||
builder.Configuration.AddJsonFile("appsettings.Development.json", true, true);
|
builder.Configuration.AddJsonFile("./appsettings.Development.json", true, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
builder.Configuration.AddJsonFile("appsettings.json", true, true);
|
builder.Configuration.AddJsonFile("./appsettings.json", true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.Host.UseSerilog((context, provider, logger) =>
|
builder.Host.UseSerilog((context, provider, logger) =>
|
||||||
{
|
{
|
||||||
logger
|
logger
|
||||||
.ReadFrom.Configuration(context.Configuration)
|
.ReadFrom.Configuration(context.Configuration)
|
||||||
.ReadFrom.Services(provider)
|
.ReadFrom.Services(provider);
|
||||||
.Enrich.FromLogContext()
|
|
||||||
.Enrich.WithExceptionDetails()
|
|
||||||
.Enrich.WithThreadName()
|
|
||||||
.Enrich.WithThreadId();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
|
|||||||
@@ -2,7 +2,13 @@
|
|||||||
"Serilog": {
|
"Serilog": {
|
||||||
"Using": [
|
"Using": [
|
||||||
"Serilog.Sinks.Console",
|
"Serilog.Sinks.Console",
|
||||||
"Serilog.Sinks.File"
|
"Serilog.Sinks.File",
|
||||||
|
"Serilog.Sinks.Async",
|
||||||
|
"Serilog.Settings.Configuration",
|
||||||
|
"Serilog.Expressions",
|
||||||
|
"Serilog.Exceptions",
|
||||||
|
"Serilog.Enrichers.Context",
|
||||||
|
"Serilog.Enrichers.Thread"
|
||||||
],
|
],
|
||||||
"MinimumLevel": {
|
"MinimumLevel": {
|
||||||
"Default": "Verbose",
|
"Default": "Verbose",
|
||||||
|
|||||||
@@ -2,12 +2,18 @@
|
|||||||
"Serilog": {
|
"Serilog": {
|
||||||
"Using": [
|
"Using": [
|
||||||
"Serilog.Sinks.Console",
|
"Serilog.Sinks.Console",
|
||||||
"Serilog.Sinks.File"
|
"Serilog.Sinks.File",
|
||||||
|
"Serilog.Sinks.Async",
|
||||||
|
"Serilog.Settings.Configuration",
|
||||||
|
"Serilog.Expressions",
|
||||||
|
"Serilog.Exceptions",
|
||||||
|
"Serilog.Enrichers.Context",
|
||||||
|
"Serilog.Enrichers.Thread"
|
||||||
],
|
],
|
||||||
"MinimumLevel": {
|
"MinimumLevel": {
|
||||||
"Default": "Verbose",
|
"Default": "Information",
|
||||||
"Override": {
|
"Override": {
|
||||||
"Microsoft": "Verbose"
|
"Microsoft": "Information"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"WriteTo": [
|
"WriteTo": [
|
||||||
|
|||||||
Reference in New Issue
Block a user