我的Windows事件查看器未按预期记录到我的事件查看器。
public class Eventlog : LogDate
{
public void logEvent(string answer)
{
this.localDate = new DateTime();
try
{
string sSource;
string sLog;
string sEvent;
sSource = "dotNET Sample App";
sLog = "filmdatabase";
sEvent = answer;
if (!EventLog.SourceExists(sSource))
{
EventLog.CreateEventSource(sSource, sLog);
}
EventLog.WriteEntry(sSource, sEvent, EventLogEntryType.Error, 234, 1);
}
catch (Exception exc)
{
MessageBox.Show("Oops! Something went wrong trying to log. \n\n" + exc , "Filmdatabase Error");
}
}
}
}
当我尝试登录时,它只会记录:启动数据库' db_film'。 而不是应用程序中的错误和警告。