refactor: Ersetzen der Methode CurrentDomainOnUnhandledException durch eine Lambda-Funktion zum Umgang mit nicht behandelten Ausnahmen
This commit is contained in:
parent
fe01e04966
commit
7ab24c696b
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user