private static bool IsExceptionKnown(Exception ex)
        {
            System.Threading.ThreadAbortException threadAbortException = ex as System.Threading.ThreadAbortException;
            if (null != threadAbortException)
            {
                return(true);
            }

            System.Messaging.MessageQueueException messageQueueException = ex as System.Messaging.MessageQueueException;
            if (null != messageQueueException && messageQueueException.MessageQueueErrorCode == System.Messaging.MessageQueueErrorCode.IOTimeout)
            {
                return(true);
            }

            System.Xml.XmlException xmlException = ex as System.Xml.XmlException;
            if (null != xmlException && xmlException.Message.StartsWith("Name cannot begin with the '<' character"))
            {
                return(true);
            }

            System.IO.FileNotFoundException fileNotFoundException = ex as System.IO.FileNotFoundException;
            if (null != fileNotFoundException &&
                null != fileNotFoundException.FileName &&
                fileNotFoundException.FileName.Contains("XmlSerializers"))
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
        protected void Application_Error(object sender, EventArgs e)
        {
            Exception ex = Server.GetLastError();

            if (null == ex)
            {
                return;
            }

            System.Threading.ThreadAbortException threadAbortException = ex as System.Threading.ThreadAbortException;
            if (null != threadAbortException)
            {
                return;
            }

            string requestUrl = HttpContext.Current.Request.Url.ToString();

            ex.AddDbgMsg("Request = {0}", requestUrl);

            if (ex.Message == "File does not exist." && requestUrl.Contains("CmgGeneralConfig.svc"))
            {
                // Suppress errors from configuration services to avoid main log pollution
                Tracer.Trace("Suppressed exception from configuration services: " + ex.ToDebugString());
                ex.Swallow();
            }
            else
            {
                ex.Trace();
            }

            Server.ClearError();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Method to write application wide exception log.
        /// </summary>
        /// <param name="ex">Object of Class Exception</param>
        public static void WriteExceptionLog(Exception ex)
        {
            System.Threading.ThreadAbortException exception = ex as System.Threading.ThreadAbortException;
            if (exception == null)
            {
                string ExceptionLogFolderPath = Environment.CurrentDirectory + @"ExceptionLog";
                try
                {
                    if (!Directory.Exists(ExceptionLogFolderPath))
                    {
                        Directory.CreateDirectory(ExceptionLogFolderPath);
                    }

                    if (Directory.Exists(ExceptionLogFolderPath))
                    {
                        //Create month wise exception log file.
                        string date  = string.Format("{0:dd}", DateTime.Now);
                        string month = string.Format("{0:MMM}", DateTime.Now);
                        string year  = string.Format("{0:yyyy}", DateTime.Now);

                        string folderName  = month + year; //Feb2013
                        string monthFolder = ExceptionLogFolderPath + "\\" + folderName;
                        if (!Directory.Exists(monthFolder))
                        {
                            Directory.CreateDirectory(monthFolder);
                        }

                        string ExceptionLogFileName = monthFolder +
                                                      "\\ExceptionLog_" + date + month + ".txt"; //ExceptionLog_04Feb.txt

                        using (System.IO.StreamWriter strmWriter = new System.IO.StreamWriter(ExceptionLogFileName, true))
                        {
                            strmWriter.WriteLine("On " + DateTime.Now.ToString() +
                                                 ", following error occured in the application:");
                            strmWriter.WriteLine("Message: " + ex.Message);
                            //strmWriter.WriteLine("Inner Exception: " + ex.InnerException.Message);
                            //strmWriter.WriteLine("Inner Exception(2): " + ex.InnerException.InnerException.Message);
                            strmWriter.WriteLine("Source: " + ex.Source);
                            strmWriter.WriteLine("Stack Trace: " + ex.StackTrace);
                            strmWriter.WriteLine("HelpLink: " + ex.HelpLink);
                            strmWriter.WriteLine("-------------------------------------------------------------------------------");
                        }
                    }
                    else
                    {
                        throw new DirectoryNotFoundException("Exception log folder not found in the specified path");
                    }
                }
                catch
                {
                }
            }
        }
 void System.Threading.IThreadPoolWorkItem.MarkAborted(System.Threading.ThreadAbortException tae)
 {
 }