ASP.NET程序向Event Viewer写入Event Log
来源:互联网 发布:神武2手游多开软件 编辑:程序博客网 时间:2024/05/01 22:51
/*By Jiangong SUN*/
在web.config中的appsettings中写入
<!--Event Log--><add key="EventLog" value="Application" /><add key="EventSource" value="Project" />
在项目中global.asax中
protected void Application_Start(object sender, EventArgs e){ Log.Configure(Settings.EventSource, Settings.EventLog); }
在Log类中
public class Log { static string source; public static void Configure(string eventSource, string eventLog) { // Create the source, if it does not already exist. if (!EventLog.SourceExists(eventSource,".")) { EventLog.CreateEventSource(eventSource, eventLog); } source = eventSource; } public static void Error(string message) { Write(message, EventLogEntryType.Error); } public static void Error(string message, Exception e) { Write(message + "\n\n" + e.ToString(), EventLogEntryType.Error); } public static void Info(string message) { Write(message, EventLogEntryType.Information); } public static void Fatal(string message, Exception e) { Write(message + "\n\n" + e.ToString(), EventLogEntryType.Error); } static void Write(string message, EventLogEntryType type) { EventLog myLog = new EventLog(); myLog.Source = source; myLog.WriteEntry(message, type); } }
在Settings类中
public static class Settings
{ public static string EventSource { get { return WebConfigurationManager.AppSettings["EventSource"]; } } public static string EventLog { get { return WebConfigurationManager.AppSettings["EventLog"]; } }
}
然后打开注册表
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application
创建一个新的key,key的名字就是项目的名字Project
- ASP.NET程序向Event Viewer写入Event Log
- 向Windows Event Viewer写Log
- 如何向系统写入Event Log
- ASP.NET Event Validation
- c++写入应用程序日志(Event Log )
- c++写入应用程序日志(Event Log )
- Windows Event Viewer understanding
- Event Viewer 问题:Event Log service on Local Computer. Error 5: Access is denied.
- How to write event log(Event Viewer) using C++ - 用C++如何写事件日志(事件查看器)
- Servic 'VisualSVN Server' failed to start.Please check VisualSVN Server log in Event Viewer for more
- Asp.net页面事件(Event)集合
- Event Calendar [ ASP.NET 2.0 / C# ]
- ASP.NET TextBox Support KeyPress Down Event
- ASP.NET 2.0 的 Event Validation
- ASP.NET 网页生命周期&各种事件Event
- asp.net textbox textchanged event not fire
- windows service event log
- IoWriteErrorLogEntry生成Event Log
- How Browsers Work:Behind the Scenes of Modern Web Browser
- emis相关的一些备忘
- 生产者与消费者模型Linux下C语言的实现
- 完善计算机体系知识
- 随笔一篇
- ASP.NET程序向Event Viewer写入Event Log
- Effective C++读书笔记之二
- 傅里叶变换在图像处理中的应用
- C#学习笔记16——.net中System.Security.Cryptography 命名空间
- Unity3D 学习
- 移植 linux-2.6.32.2 到 mini2440
- 李商隐“忘恩负义”:做恩人死敌的女婿成“污点”
- CT的DICOM图象常用标签
- JS冒泡事件解决方案