Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Oct 24, 2011 08:54 PM by Nilla2010
Oct 24, 2011 08:54 PM|LINK
I am using log4net to log the errors in my application .Eveything works fine for the initial setup and logging. Now i want to set the Category and Event in the Eventlog.
I am using the below code to log the EventID ,but not sure about the category.
log4net.ThreadContext.Properties["EventID"] = 5;
Also how to differenciate the error levels [like i am getting the error message from Global.asax and logging the message to Eventlogs.But all the errors are going to log.error as below
if ((log.IsErrorEnabled) && ((checkException.GetHttpCode() == 500) || (checkException.GetHttpCode() == 404)))
if(checkException.GetHttpCode() == 500)
log4net.ThreadContext.Properties["Category"] = "500";
log4net.ThreadContext.Properties["Category"] = "404";
log.Error("Error" + sbErrorMessage.ToString() );
else if (log.IsInfoEnabled)
log.Warn("Information" + sbErrorMessage.ToString());
else if (log.IsWarnEnabled)
log.Info("Warning" + sbErrorMessage.ToString());
I am not quite clear here..Like if i get an "InvalidOperationException" its an warning but the httpcode is 500 and it gets logged as "Error". I tried to get sbErrorMessage.innerExeception but its null.
Thanks in advance
I want all the errors,warning and information to be logged in one EventLog