P
Paperback Writer
Hi, I'm trying to write a eventlog in my Application_Error but does not work
I tryed by using SmtpMail and worked fine, but the EventLog not! =[
The code:
Exception ex = Server.GetLastError().GetBaseException();
string msgErro = ex.Message;
msgErro += "\n" + ex.StackTrace;
// Create the source, if it does not already exist.
if(!System.Diagnostics.EventLog.SourceExists("MySource", "MyServer"))
{
System.Diagnostics.EventLog.CreateEventSource("MySource", "MyNewLog",
"MyServer");
Console.WriteLine("CreatingEventSource");
}
// Create an EventLog instance and assign its source.
System.Diagnostics.EventLog myLog = new System.Diagnostics.EventLog();
myLog.Source = "MySource";
// Write an informational entry to the event log.
myLog.WriteEntry(msgErro);
--
Thanks in advance,
Daniel Groh
CTF Technologies do Brasil Ltda.
Analista Programador
Fone: 11 3837-4203
E-mail: (e-mail address removed)
I tryed by using SmtpMail and worked fine, but the EventLog not! =[
The code:
Exception ex = Server.GetLastError().GetBaseException();
string msgErro = ex.Message;
msgErro += "\n" + ex.StackTrace;
// Create the source, if it does not already exist.
if(!System.Diagnostics.EventLog.SourceExists("MySource", "MyServer"))
{
System.Diagnostics.EventLog.CreateEventSource("MySource", "MyNewLog",
"MyServer");
Console.WriteLine("CreatingEventSource");
}
// Create an EventLog instance and assign its source.
System.Diagnostics.EventLog myLog = new System.Diagnostics.EventLog();
myLog.Source = "MySource";
// Write an informational entry to the event log.
myLog.WriteEntry(msgErro);
--
Thanks in advance,
Daniel Groh
CTF Technologies do Brasil Ltda.
Analista Programador
Fone: 11 3837-4203
E-mail: (e-mail address removed)