private static void EnabledUnhandledExceptionsLogging()
{
if (_unhandledExceptionLoggingInitialized) return;
AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
{
var ex = (Exception)args.ExceptionObject;
Log.LogCritical("Unhandled exception", ex);
LogManager.Flush();
};
_unhandledExceptionLoggingInitialized = true;
}