diff --git a/src/Core/Settings/GlobalSettings.cs b/src/Core/Settings/GlobalSettings.cs index 93a7188ca..ef80935b3 100644 --- a/src/Core/Settings/GlobalSettings.cs +++ b/src/Core/Settings/GlobalSettings.cs @@ -25,6 +25,7 @@ public class GlobalSettings : IGlobalSettings set => _logDirectory = value; } public virtual long? LogRollBySizeLimit { get; set; } + public virtual bool EnableDevLogging { get; set; } = false; public virtual string LicenseDirectory { get => BuildDirectory(_licenseDirectory, "/core/licenses"); diff --git a/src/Core/Utilities/LoggerFactoryExtensions.cs b/src/Core/Utilities/LoggerFactoryExtensions.cs index c94df3960..f6ea43882 100644 --- a/src/Core/Utilities/LoggerFactoryExtensions.cs +++ b/src/Core/Utilities/LoggerFactoryExtensions.cs @@ -20,7 +20,7 @@ public static class LoggerFactoryExtensions IHostApplicationLifetime applicationLifetime, GlobalSettings globalSettings) { - if (env.IsDevelopment()) + if (env.IsDevelopment() && !globalSettings.EnableDevLogging) { return; } @@ -33,14 +33,14 @@ public static class LoggerFactoryExtensions WebHostBuilderContext context, Func filter = null) { - if (context.HostingEnvironment.IsDevelopment()) + var globalSettings = new GlobalSettings(); + ConfigurationBinder.Bind(context.Configuration.GetSection("GlobalSettings"), globalSettings); + + if (context.HostingEnvironment.IsDevelopment() && !globalSettings.EnableDevLogging) { return builder; } - var globalSettings = new GlobalSettings(); - ConfigurationBinder.Bind(context.Configuration.GetSection("GlobalSettings"), globalSettings); - bool inclusionPredicate(LogEvent e) { if (filter == null)