diff --git a/src/Scaffolding.AspNetCore/Extensions/HostBuilderExtensions.cs b/src/Scaffolding.AspNetCore/Extensions/HostBuilderExtensions.cs index 6c66fd0..c6ef577 100644 --- a/src/Scaffolding.AspNetCore/Extensions/HostBuilderExtensions.cs +++ b/src/Scaffolding.AspNetCore/Extensions/HostBuilderExtensions.cs @@ -16,7 +16,19 @@ namespace Microsoft.Extensions.DependencyInjection; public static class HostBuilderExtensions { - public static IHostBuilder AddSerilogLogging(this IHostBuilder builder, IScaffoldingConfiguration configuration, string requestKeyHeader = "RequestKey") + /// + /// Adds serilog logging for the api. + /// + /// + /// + /// Header that will be used to set the request key for tracing across requests. + /// Flag that will log json even in development for debugging properties purposes. + /// + public static IHostBuilder AddSerilogLogging( + this IHostBuilder builder, + IScaffoldingConfiguration configuration, + string requestKeyHeader = "RequestKey", + bool debugAsConsole = false) { return builder.UseSerilog((context, loggerCfg) => { @@ -34,7 +46,7 @@ public static IHostBuilder AddSerilogLogging(this IHostBuilder builder, IScaffol .Enrich.WithProperty(nameof(applicationSettings.Domain), applicationSettings.Domain) .Enrich.With(new RemovePropertiesEnricher()); - if (!context.HostingEnvironment.IsDevelopment()) + if (context.HostingEnvironment.IsDevelopment() || debugAsConsole) { loggerCfg .WriteTo.Console() diff --git a/src/Scaffolding.sln b/src/Scaffolding.sln index 80a163f..d83f19b 100644 --- a/src/Scaffolding.sln +++ b/src/Scaffolding.sln @@ -7,8 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Scaffolding.Sample", "Scaff EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Scaffolding.Logging.Serilog", "Scaffolding.Logging.Serilog\Scaffolding.Logging.Serilog.csproj", "{C1E7E180-1222-4F99-98A7-69B0AE2C8CB8}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Scaffolding.Shared", "Scaffolding.Shared\Scaffolding.Shared.csproj", "{B52C98FD-6C4E-4B4A-BB19-98D29DE1F9FD}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Scaffolding.Configuration", "Scaffolding.Configuration\Scaffolding.Configuration.csproj", "{8AE234D6-D794-4AE5-9C86-2E50FB8132D5}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Scaffolding.HealthCheck", "Scaffolding.HealthCheck\Scaffolding.HealthCheck.csproj", "{95758A46-404E-4960-AF40-D3E2127C73CC}" @@ -41,10 +39,6 @@ Global {C1E7E180-1222-4F99-98A7-69B0AE2C8CB8}.Debug|Any CPU.Build.0 = Debug|Any CPU {C1E7E180-1222-4F99-98A7-69B0AE2C8CB8}.Release|Any CPU.ActiveCfg = Release|Any CPU {C1E7E180-1222-4F99-98A7-69B0AE2C8CB8}.Release|Any CPU.Build.0 = Release|Any CPU - {B52C98FD-6C4E-4B4A-BB19-98D29DE1F9FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B52C98FD-6C4E-4B4A-BB19-98D29DE1F9FD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B52C98FD-6C4E-4B4A-BB19-98D29DE1F9FD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B52C98FD-6C4E-4B4A-BB19-98D29DE1F9FD}.Release|Any CPU.Build.0 = Release|Any CPU {8AE234D6-D794-4AE5-9C86-2E50FB8132D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8AE234D6-D794-4AE5-9C86-2E50FB8132D5}.Debug|Any CPU.Build.0 = Debug|Any CPU {8AE234D6-D794-4AE5-9C86-2E50FB8132D5}.Release|Any CPU.ActiveCfg = Release|Any CPU