Hi All,

I am using log4net to log the errors in my application . Everything works fine 
for the initial setup and logging. Now I want to set the Category and Event in 
the Event log.

I am using the below code to log the EventID  ,but not sure about the category.

      log4net.ThreadContext.Properties["EventID"] = 5;

Also how to differentiate 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";
                else
                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());
           }

In addition ,I am not quite clear aout getting the Error,Warning and 
Information separately  ..Like if i get an "InvalidOperationException" it's 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 Event log  
as in the attached image.


Thanks,
Vanitha


________________________________

This message contains Devin Group confidential information and is intended only 
for the individual named. If you are not the named addressee you should not 
disseminate, distribute or copy this e-mail.
Please notify the sender immediately by e-mail if you have received this e-mail 
in error and delete this e-mail from your system. E-mail transmissions cannot 
be guaranteed secure, error-free and information could be intercepted, 
corrupted, lost, destroyed, arrive late, incomplete, or contain viruses. The 
sender therefore does not accept liability for errors or omissions in the 
contents of this message which may arise as result of transmission. If 
verification is required please request hard-copy version.

<<attachment: SampleEvenyLog.PNG>>

Reply via email to