LogManager: updated UnhandledException case to always write error to console along with log file.

This commit is contained in:
Shreyas Zare
2025-02-15 12:43:12 +05:30
parent 8ff63a59d1
commit 3d5989e1ba

View File

@@ -1,6 +1,6 @@
/* /*
Technitium DNS Server Technitium DNS Server
Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com) Copyright (C) 2025 Shreyas Zare (shreyas@technitium.com)
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -81,12 +81,10 @@ namespace DnsServerCore
AppDomain.CurrentDomain.UnhandledException += delegate (object sender, UnhandledExceptionEventArgs e) AppDomain.CurrentDomain.UnhandledException += delegate (object sender, UnhandledExceptionEventArgs e)
{ {
if (!_enableLogging) //log to console immediately
{
Console.WriteLine(e.ExceptionObject.ToString()); Console.WriteLine(e.ExceptionObject.ToString());
return;
}
//try log to file
lock (_queueLock) lock (_queueLock)
{ {
try try
@@ -103,7 +101,6 @@ namespace DnsServerCore
{ } { }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine(e.ExceptionObject.ToString());
Console.WriteLine(ex.ToString()); Console.WriteLine(ex.ToString());
} }
finally finally