Skip to content

Shutdown: Unsubscribe from AppDomain event handlers #256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/log4net/Core/LoggerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ public static ILogger GetLogger(Assembly repositoryAssembly, Type type)
/// </remarks>
public static void Shutdown()
{
//Cleanup event handlers since they only call this mathod anyways
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//Cleanup event handlers since they only call this mathod anyways
// Cleanup event handlers since they only call this method anyways

AppDomain.CurrentDomain.ProcessExit -= OnProcessExit;
AppDomain.CurrentDomain.DomainUnload -= OnDomainUnload;

foreach (ILoggerRepository repository in GetAllRepositories())
{
repository.Shutdown();
Expand Down Expand Up @@ -572,4 +576,4 @@ private static string GetVersionInfo()
/// log message.
/// </remarks>
private static readonly Type _declaringType = typeof(LoggerManager);
}
}