diff --git a/StaffDBServer/Program.cs b/StaffDBServer/Program.cs index f25da92..9474e57 100644 --- a/StaffDBServer/Program.cs +++ b/StaffDBServer/Program.cs @@ -16,7 +16,12 @@ namespace StaffDBServer public static void Main(string[] args) { - AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException; + AppDomain.CurrentDomain.UnhandledException += (object sender, UnhandledExceptionEventArgs unhandledExceptionEventArgs) => + { + ILoggerManager logger = new LoggerManager(); + logger.LogException((Exception)unhandledExceptionEventArgs.ExceptionObject, "Application closed due to exception."); + NLog.LogManager.Flush(); + }; IConfiguration configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json", true, true).Build(); @@ -55,13 +60,5 @@ namespace StaffDBServer logging.SetMinimumLevel(LogLevel.Warning); }) .UseNLog(); - - private static void CurrentDomainOnUnhandledException(object sender, UnhandledExceptionEventArgs unhandledExceptionEventArgs) - - { - ILoggerManager logger = new LoggerManager(); - logger.LogException((Exception)unhandledExceptionEventArgs.ExceptionObject, "Application closed due to exception."); - NLog.LogManager.Flush(); - } } } \ No newline at end of file