下面的代碼沒有登錄到我的資料庫。是不是因為控制臺應用程式關閉得太快了,如果是這樣,我該如何防止這種情況?
private static ILogger _logger;
static void UnhandledExceptionTrapper(object sender, UnhandledExceptionEventArgs e)
{
_logger.Error((Exception)e.ExceptionObject);
}
private static void Main(string[] args)
{
var container = new Container();
_logger = container.GetInstance<ILogger>();
AppDomain.CurrentDomain.UnhandledException = UnhandledExceptionTrapper;
throw new Exception("test");
uj5u.com熱心網友回復:
你可以LogManager.Shutdown()在離開你的UnhandledExceptionTrapper方法之前打電話。LogManager.Flush()這在內部呼叫
重繪 所有掛起的日志訊息(在異步目標的情況下),默認超時為 15 秒。
請參閱
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/446221.html
