DnsWebService: added logging for unhandled exception using AppDomain.CurrentDomain.UnhandledException. Made change to load StatsManager in Start().

This commit is contained in:
Shreyas Zare
2018-12-23 19:19:32 +05:30
parent 7320790617
commit 3d0bd151da

View File

@@ -61,7 +61,7 @@ namespace DnsServerCore
readonly Uri _updateCheckUri;
readonly LogManager _log;
readonly StatsManager _stats;
StatsManager _stats;
string _serverDomain;
int _webServicePort;
@@ -118,12 +118,10 @@ namespace DnsServerCore
_log = new LogManager(logFolder);
string statsFolder = Path.Combine(_configFolder, "stats");
if (!Directory.Exists(statsFolder))
Directory.CreateDirectory(statsFolder);
_stats = new StatsManager(statsFolder, _log);
AppDomain.CurrentDomain.UnhandledException += delegate (object sender, UnhandledExceptionEventArgs e)
{
_log.Write((Exception)e.ExceptionObject);
};
}
#endregion
@@ -3398,6 +3396,16 @@ namespace DnsServerCore
try
{
if (_stats == null)
{
string statsFolder = Path.Combine(_configFolder, "stats");
if (!Directory.Exists(statsFolder))
Directory.CreateDirectory(statsFolder);
_stats = new StatsManager(statsFolder, _log);
}
_dnsServer = new DnsServer();
_dnsServer.RecursiveResolveProtocol = RECURSIVE_RESOLVE_PROTOCOL;
_dnsServer.LogManager = _log;