Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting maximum event log size

Why is the following code not working?

if(EventLog.Exists("Foo"))
{
     EventLog.Delete("Foo");
}

if(EventLog.Exists("Foo") == false)
{
     EventLog.CreateEventSource("Foo", "Foo");

     EventLog.GetEventLogs().First(x => x.Log == "Foo").ModifyOverflowPolicy(OverflowAction.OverwriteAsNeeded, 0);
     EventLog.GetEventLogs().First(x => x.Log == "Foo").MaximumKilobytes = 100000;
}

The overflow policy is correctly being changed, but the maximum size stays at the default 512KB. What am I doing wrong?

Thanks!

like image 751
Chris Avatar asked Sep 24 '26 02:09

Chris


1 Answers

Are you sure it's not throwing an exception? The MaximumKilobytes value must be divisible by 64.

See:

http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.maximumkilobytes.aspx

like image 57
TinaMarie Avatar answered Sep 26 '26 16:09

TinaMarie



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!