log for application error

Posted by Abhi_patil under ASP.NET on 4/18/2009 | Views : 959 | Status : [Member] | Replies : 1
i have created log directory for errors in application_error() of global.asax page.
my code is as follows..

try
{

StackFrame callstack = new StackFrame(1, true);
int lineNo = callstack.GetFileLineNumber();
//string user = "User: " + Session["Username"].ToString();
string msg2 = "\n Line No: " + lineNo + "\nIP: " + IPAddress;
string strError = "\nError in: " + Request.Url.ToString() +
"\nError Message: " + objError.Message.ToString() +
"\nStack Trace: " + objError.StackTrace;

msg2 += strError;
string errorLogname = "ErrorSample";
if (EventLog.SourceExists(errorLogname) == false)
{
EventLog.CreateEventSource(errorLogname, errorLogname);
}
EventLog log = new EventLog();
log.Source = errorLogname;
log.WriteEntry(msg2, EventLogEntryType.Error, lineNo);
}
catch (Exception ex) { }


but the log directory with name ErrorSample is created in event viewer on windows xp poffessional ,
i want to it should be created on windows 2003 server,
i also tried it on win. 2003 server, bur it didnot created..
plz reply how to check log on windows 2003 serverr..




Responses

Posted by: Vuyiswamb on: 4/22/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Good Afternoon

Look at this

http://www.xdevsoftware.com/blog/post/Export-Event-Logs-Windows-2003-in-NET---C.aspx


Thank you for Posting at DotnetFunda


Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Abhi_patil, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response