为什么以下代码不起作用?
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。我做错了什么?
谢谢!
答案 0 :(得分:2)
你确定没有抛出异常吗? MaximumKilobytes值必须可被64整除。
请参阅:
http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.maximumkilobytes.aspx