IOException 寫入事件日誌 (IOException writing to event log)


問題描述

IOException 寫入事件日誌 (IOException writing to event log)

我們今天遇到了這個異常,每次我們重試導致它的操作時都會重複

System.IO.IOException: Insufficient system resources exist to complete the requested service.

   at Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str)
   at Microsoft.Win32.RegistryKey.SetValue(String name, Object value, RegistryValueKind valueKind)
   at System.Diagnostics.EventLog.CreateEventSource(EventSourceCreationData sourceData)
   at System.Diagnostics.EventLog.VerifyAndCreateSource(String sourceName, String currentMachineName)
   at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)
   at System.Diagnostics.EventLog.WriteEntry(String source, String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)
   at System.Diagnostics.EventLog.WriteEntry(String source, String message)
   at DoWork()

重新啟動為我們解決了這個問題,但沒有解釋根本原因。我們通常編寫少於 20 個字符的源代碼和少於 100 個字符的消息。運行代碼的機器上的資源使用情況似乎很好。


參考解法

方法 1:

I dug in a little deeper after the reboot was done and got a copy of the application log from the event viewer. There were ~66,000 events for that day only. I wrote a test app to write 66,000 unique messages to the log and it completed pretty quickly.

Then I noticed we had a different source for every 10 or so messages so I changed my test app to write a unique source and message every time. After about 15 minutes it only wrote 6000.

Though I wasn't able to reproduce the exception in the question I believe our problem was that we were creating new EventSources needlessly and often which goes against the recommended way of writing to the event log.

As an addendum, if the sources already existed, it wouldn't be nearly as big an issue

(by CiaranCiaran)

參考文件

  1. IOException writing to event log (CC BY‑SA 2.5/3.0/4.0)

#windows-server-2003 #event-log #.net






相關問題

Metode Dll tidak dipanggil di windows server 2008 (Dll methods are not invoked on windows server 2008)

刪除窗口別名 (Removing windows aliases)

從 IIS 6 升級到 8.5:增加並發請求 (Upgrading from IIS 6 to 8.5: increased concurrent requests)

IOException 寫入事件日誌 (IOException writing to event log)

底層連接已關閉:接收時發生意外錯誤 (The underlying connection was closed: An unexpected error occurred on a receive)

Win2003終端服務器的小程序加載問題 (Applet loading problem with Win2003 Terminal Server)

確保在 Windows Server 2003 64 位上安裝了 ASP.NET 3.5 Framework (Ensure that ASP.NET 3.5 Framework is installed on Windows Server 2003 64-bit)

為沒有證書模板的 PKCS#10 CSR 頒發證書。0x80094801 MS W2K3企業CA (Issue certificate for a PKCS#10 CSR without Cert template. 0x80094801 MS W2K3 enterprise CA)

操作系統升級後無法從 ANT 訪問環境變量 (Can't access env vars from ANT after OS upgrade)

在 Windows 上自動啟動批處理文件 (Autostart a batch file on Windows)

為什麼從 PHP 腳本調用 (ImageMagick) convert.exe 會導致頁面無響應? (Why is calling (ImageMagick) convert.exe from PHP script resulting in an unresponsive page?)

即使在修補程序之後 SHA256 也無法正常工作 (SHA256 not working even after hotfixes)







留言討論