0
我們使用微軟的Enterprise Library(4.1),並經常有以下問題:企業庫ExceptionManager:「日誌條目字符串太長。」
[ArgumentException: Log entry string is too long. A string written to the event log cannot exceed 32766 characters.]
System.Diagnostics.EventLog.InternalWriteEvent(UInt32 eventID, UInt16 category, EventLogEntryType type, String[] strings, Byte[] rawData, String currentMachineName) +1005489
System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData) +264
System.Diagnostics.EventLog.WriteEntry(String source, String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData) +87
System.Diagnostics.EventLog.WriteEntry(String source, String message, EventLogEntryType type) +14
Microsoft.ApplicationBlocks.ExceptionManagement.DefaultPublisher.WriteToLog(String entry, EventLogEntryType type) in D:\temp\Exception Management\Code\CS\Microsoft.ApplicationBlocks.ExceptionManagement\ExceptionManager.cs:647
Microsoft.ApplicationBlocks.ExceptionManagement.DefaultPublisher.Publish(Exception exception, NameValueCollection additionalInfo, NameValueCollection configSettings) in D:\temp\Exception Management\Code\CS\Microsoft.ApplicationBlocks.ExceptionManagement\ExceptionManager.cs:634
Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.PublishToDefaultPublisher(Exception exception, NameValueCollection additionalInfo) in D:\temp\Exception Management\Code\CS\Microsoft.ApplicationBlocks.ExceptionManagement\ExceptionManager.cs:287
Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish(Exception exception, NameValueCollection additionalInfo) in D:\temp\Exception Management\Code\CS\Microsoft.ApplicationBlocks.ExceptionManagement\ExceptionManager.cs:232
Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish(Exception exception) in D:\temp\Exception Management\Code\CS\Microsoft.ApplicationBlocks.ExceptionManagement\ExceptionManager.cs:66
...
不幸的是,DefaultPublisher
的WriteToLog
方法不執行任何邊界寫入事件日誌所以我們原來的堆棧跟蹤丟失前檢查。
有沒有辦法解決這個問題(最好是通過配置)並仍然使用DefaultPublisher
?