Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows EventLog cannot exceed 32766 characters

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)

like image 863
marstone Avatar asked Jul 13 '26 10:07

marstone


1 Answers

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.

like image 64
Joe Avatar answered Jul 15 '26 11:07

Joe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!