The EventLog and Message limits
Note: this entry has moved.
Sometimes I have to fix certain issues in BizTalk and during one of these exercises I had to write a large message into the eventlog.OUCH! Ok now who does that ? Well I’m not at fault here but then again we did require this for some convoluted reason. Anyway there was some whacky boundary condition code. So to get a quick value just decided to flood my event log and see how much can it store.
static void Main(string[] args)
{
int limit=31000;
int source = 10; //212 is the limit here.
while(true)
{
try
{
SD.EventLog.WriteEntry(new string('s',source) , new string('v', limit), System.Diagnostics.EventLogEntryType.Information, 0, 0);
limit++;
}
catch (Win32Exception ex)
{
Console.WriteLine(--limit);
break;
}
}SD.EventLog.WriteEntry(new string('s', source), new string('v', limit), System.Diagnostics.EventLogEntryType.Information, 0, 0);
Console.WriteLine("Total = " + (source + limit));
}
And guess – its a magic number 31884 and not 32k. System.Diagnostics.Eventlog actually uses advapi32!ReportEvent but this seems to have a 32k limit. Anyway short answer is that its not “exactly” 32k.