开发者

Windows EventLog cannot exceed 32766 characters

开发者 https://www.devze.com 2023-04-11 20:14 出处:网络
when i write log to windows eventlog: System.Diagnostics.EventLog.WriteEntry(\"SourceName\", a_long_string);

when i write log to windows eventlog:

System.Diagnostics.EventLog.WriteEntry("SourceName", a_long_string);

i got the following exception:

开发者_运维知识库

Log entry string is too long. A string written to the event log cannot exceed 32766 characters.

then i splits my log message into 2 or more string. but i don't think it is a good idea. any workarounds? (such as extern the limit per log entry)


The Event Log isn't intended for storing Chapter 1 of War and Peace. You really should reconsider what you're writing to the event log.

If you want to log something voluminous (e.g. a crash dump), you can always store it somewhere on disk and write a message to the EventLog something like Generated dump at C:\Users\MyUserName\AppData\Local\MyApp\WarAndPeace.pdf.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号