尝试从控制台应用程序写入事件日志时,我不断收到此错误消息.这是我写给它的方式
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());
}
Run Code Online (Sandbox Code Playgroud)
有谁知道为什么会这样,以及我如何解决它?
我使用Visual C#2010 Express在Windows XP上遇到了同样的错误,这对我有用:
转到开始 - >控制面板 - >管理工具 - >事件查看器
然后选择Action-> Properties并选择"根据需要覆盖事件"
您还可以增加日志的最大大小.
| 归档时间: |
|
| 查看次数: |
16857 次 |
| 最近记录: |