在注册表 System->CurrentControlSet->Services->Eventlog 处选择添加系统中 AspNet 这个账户注意是在右键的 安全->权限->添加
写日志
public static void Log(string sourceName, string message)
{
EventLog eventLog = null;
if (!(EventLog.SourceExists(sourceName)))
{
EventLog.CreateEventSource(sourceName, sourceName + "Log");
}
if (eventLog == null)
{
eventLog = new EventLog(sourceName + "Log");
eventLog.Source = sourceName;
}
eventLog.WriteEntry(message, System.Diagnostics.EventLogEntryType.Information);
}
sourceName 为日志名