用EventLog类如何把日志文件写道一个指定目录下的日志文件中?

linuxyf 2004-12-16 09:55:28
if(!EventLog.SourceExists("MySource"))
{
EventLog.CreateEventSource("MySource", "F:\ooo.log");
}
EventLog oEV = new EventLog();
oEV.Source = "MySource";
oEV.WriteEntry(strError, System.Diagnostics.EventLogEntryType.Error);
为什么我执行完以后没有日志文件生成?
...全文
229 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
biliboy 2005-07-08
  • 打赏
  • 举报
回复
Mark
JackLucifer 2005-06-19
  • 打赏
  • 举报
回复
mark
wangxt 2004-12-17
  • 打赏
  • 举报
回复
帮你顶
saucer 2004-12-17
  • 打赏
  • 举报
回复
那么就别用EventLog,自己写个TraceListener,然后用System.Diagnostics.Trace写记录,
http://www.eggheadcafe.com/articles/20041116.asp

或者用log4net。如果你主要是管理exception的话,用微软的Exception Management Application Block

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/emab-rm.asp

Custom publishers for the Exception Management Application Block
http://builder.com.com/5100-6374-5110833.html
linuxyf 2004-12-17
  • 打赏
  • 举报
回复
还有其他的选择吗?
看看Java下面选择的余地多大,C#还是感觉不爽。
北京的雾霾天 2004-12-16
  • 打赏
  • 举报
回复
如果你要想写到日志文件里那就自己用System.IO.StreamWriter来写就是了,不要用System.Diagnostics.EventLog了.
linuxyf 2004-12-16
  • 打赏
  • 举报
回复
兄弟,这个类能不能把日志信息记录到指定的日志文件中???
youwanna 2004-12-16
  • 打赏
  • 举报
回复
在管理工具里面的事件查看器里面已经有日志了

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧