Hi, After spending a week for the log4net implementation which has to log errors from both aspx and asp files , i am still out with no luck. This is my scenario, my project contains both asp and aspx pages. The aspx page errors are captured in Globals.asax and send to Errorlogging.dll ,where i have log4net implemention to log the errors to EventViewer and its works just fine.
Other part is for ASP pages ,i am accesing the same Errorlogging.dll ,but different method to log the error. Here isDebugenabled is true,but the errors are not logged into the EventViewer. 1.I am using the same Eventviewer log file for both methods 2.The method which logs aspx errors ,take the configurations from web.config 3.But for the method which logs asp errors,i am using seperate log4net.config file. Questions Do i need to maintain two diffferent config's for each methods? I dont think its permission issue, bse the other method works just fine. Only thing is the config section . Is there any locking issue here Thanks, CODE public static readonly ILog log = LogManager.GetLogger(typeof(ErrorLogging).Name); public ErrorLogging() { } //ASP public String logEventErrorASP(String sourceName, String logName, String objErr, String strBotListPath) { // log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "log4net.config")); log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(Path.GetDirectoryName(Assembly.GetAssembly(GetType()).Location) + @"\" + "log4net.config")); String tempVar=Path.GetDirectoryName(Assembly.GetAssembly(GetType()).Location) + @"\" + "log4net.config"; //log4net.Config.XmlConfigurator.Configure(); //log4net.ThreadContext.Properties["EventID"] = 5; String tempdata = string.Empty; if (!System.Diagnostics.EventLog.SourceExists(sourceName)) { tempdata = sourceName + logName + objErr + strBotListPath; System.Diagnostics.EventLog.CreateEventSource(sourceName, logName); } else { // Exception ex = (Exception)objErr; if (log.IsErrorEnabled) { log.Error("There is an error " + objErr); tempdata = "Warning "; } if (log.IsWarnEnabled) { tempdata = tempdata + "Fatal"; try { log.Warn(" Unhandled error!" + objErr); } catch (Exception ex) { tempdata = tempdata + ex.ToString(); } } } return tempdata + " "+ tempVar; //return ConfigurationSettings.AppSettings["log4net.config"].ToString(); } //ASP.NET public String logEventError(String sourceName, String logName, HttpContext errContext, HttpRequest errRequest, Exception objErr, string strBotListPath) { log4net.Config.XmlConfigurator.Configure(); log4net.ThreadContext.Properties["EventID"] = 5; if (!System.Diagnostics.EventLog.SourceExists(sourceName)) { System.Diagnostics.EventLog.CreateEventSource(sourceName, logName); } if (log.IsErrorEnabled) { log.Error("Page Load failed : " + objErr); } //Custom Error Page string strErrorPage; HttpException checkException = new HttpException(); if (objErr.GetType() == typeof(HttpException)) { checkException = (HttpException)objErr; } if (checkException.GetHttpCode() == 404) { strErrorPage = "~/404.aspx"; } else { strErrorPage = "~/500.aspx"; } //if (blnLog404 || checkException.GetHttpCode() != 404) //{ if (File.Exists(strBotListPath)) { XmlDocument document = new XmlDocument(); document.Load(strBotListPath); XmlNodeList xmlUserAgentList = document.SelectNodes("//UserAgent"); foreach (XmlNode node in xmlUserAgentList) { string botName = node.InnerText.ToString(); //string botName = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"; bool isBot = errRequest.ServerVariables["ALL_RAW"].ToUpper().Contains(botName.ToUpper()); if (isBot) { return strErrorPage; } } } return strErrorPage; } ________________________________ 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.