2

为什么以下代码不起作用?

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;
}

溢出策略已正确更改,但最大大小保持在默认的 512KB。我究竟做错了什么?

谢谢!

4

1 回答 1

2

你确定它没有抛出异常吗?MaximumKilobytes 值必须能被 64 整除。

看:

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

于 2009-11-05T18:11:59.703 回答