事件日志文件已满
尝试从控制台应用程序写入事件日志时,我不断收到此错误消息。 这是我写的方式
public static void WriteToEventLog(Exception ex)
{
string mySource = "Export Task";
if (!EventLog.SourceExists(mySource))
EventLog.CreateEventSource(mySource, "Application");
EventLog myLog = new EventLog();
myLog.Source = mySource;
myLog.WriteEntry(ex.ToString());
}
有谁知道为什么会发生这种情况以及我该如何解决它?
I keep getting this error message when trying to write to the Event log from a console app.
Here's how i write to it
public static void WriteToEventLog(Exception ex)
{
string mySource = "Export Task";
if (!EventLog.SourceExists(mySource))
EventLog.CreateEventSource(mySource, "Application");
EventLog myLog = new EventLog();
myLog.Source = mySource;
myLog.WriteEntry(ex.ToString());
}
Does anyone know why this is happening and how i can fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(7)
森末i2024-08-09 11:33:30
最有可能的情况是,您正在使用默认的应用程序日志,该日志通常由您计算机上的几乎所有应用程序写入(就像您编写的应用程序一样)。随着时间的推移,事件日志会填满并达到最大值,
因此我的建议是创建一个 新的自定义事件日志而不是重用“应用程序”日志。这样您就可以捕获此异常(这是一个有效的情况)并通过调用 EventLog.Clear &重试写入事件操作。还要检查您是否淹没了事件日志,负责任地记录。
另一方面,您还可以更改应用程序日志的事件日志属性。 (事件查看器,调出应用程序日志节点上的属性) - 您可以指定日志的最大大小 (512 KB) 以及如何处理包装,例如,在达到最大大小时覆盖超过 7 天的条目。 (这似乎是我的 WinXP 机器上的默认设置)。但你必须在每台机器上都这样做......但你可以尝试一下
~没有更多了~
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
对我来说,这听起来像是:
如果情况并非如此,请编辑您的问题,以明确您认为事件日志未满,以及您如何得出此结论。
To me it sounds like:
If this isn't the case, please edit your question to make it clear that you believe the event log isn't full, and how you came to this conclusion.