Skip to content

Commit 0f34501

Browse files
authoredJul 14, 2022
Introduced NLogProviderOptions AutoShutdown that is turned off by default (#606)
1 parent c731661 commit 0f34501

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed
 

‎src/NLog.Extensions.Hosting/Extensions/ConfigureExtensions.cs

-5
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,6 @@ private static NLogLoggerProvider CreateNLogLoggerProvider(IServiceProvider serv
6363
TryLoadConfigurationFromContentRootPath(provider.LogFactory, contentRootPath);
6464
}
6565

66-
if (provider.Options.ShutdownOnDispose)
67-
{
68-
provider.LogFactory.AutoShutdown = false;
69-
}
70-
7166
return provider;
7267
}
7368

‎src/NLog.Extensions.Logging/Internal/RegisterNLogLoggingProvider.cs

+5
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ internal static NLogLoggerProvider CreateNLogLoggerProvider(this IServiceProvide
8080
provider.TryLoadConfigurationFromSection(configuration);
8181
}
8282

83+
if (provider.Options.ShutdownOnDispose || !provider.Options.AutoShutdown)
84+
{
85+
provider.LogFactory.AutoShutdown = false;
86+
}
87+
8388
return provider;
8489
}
8590

‎src/NLog.Extensions.Logging/Logging/NLogProviderOptions.cs

+5
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ public class NLogProviderOptions
5050
/// </summary>
5151
public bool ShutdownOnDispose { get; set; }
5252

53+
/// <summary>
54+
/// Automatically Shutdown NLog on AppDomain.Unload or AppDomain.ProcessExit
55+
/// </summary>
56+
public bool AutoShutdown { get; set; }
57+
5358
#if NET5_0
5459
/// <summary>
5560
/// Automatically include <see cref="System.Diagnostics.Activity.SpanId"/>, <see cref="System.Diagnostics.Activity.TraceId"/> and <see cref="System.Diagnostics.Activity.ParentId"/>

0 commit comments

Comments
 (0)
Please sign in to comment.