Sitecore 500 Registration / Error Alerts

Problem

I'm currently looking to serve a custom page with an error of 500, as well as register and warn webmasters about the status that was hit (which URL, stack trace, timestamp, etc.).

I tried certain custom HTTP errors in the system configuration, but the error pages did not suffer. I can handle 404s and related errors (layoutnotfound).

Question

Should I intercept the context in global.asax to handle 500 errors and return the user page? Is there any other way with Sitecore to achieve what I'm looking for?

Basically, I'm looking for best practice logging / alerts for 500 bugs with Sitecore

+3
source share
3

ELMAH.

- Sitecore.

+5

- . log4net . , , application_error global.asax, . , .

, , ​​ url ​​ Current sitecore item:

        private static readonly ILog log = LogManager.GetLogger(typeof(Global));
        protected void Application_Error(object sender, EventArgs e)
        {
            if (Context != null)
            {
                Exception error = Context.Server.GetLastError().GetBaseException();
                log.Fatal(
                    GetErrorMessage(), error);
            }
        }
        private string GetErrorMessage()
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("Application_Error: Unhandled exception has been occured.");
            try
            {
                sb.AppendLine("Current Request: " + Context.Request.RawUrl);
                Sitecore.Data.Items.Item currentItem = Sitecore.Context.Item;
                if (currentItem != null)
                    sb.AppendLine(String.Format("Current Item ({0}): {1}", currentItem.ID, currentItem.Paths.FullPath));
                if (Sitecore.Context.Database != null)
                    sb.AppendLine("Current Database: " + Sitecore.Context.Database.Name);
            }
            catch { } // in no way should we prevent the site from logging the error
            return sb.ToString();

        }

, Elmah. , log4net.

+5

HTTP- , . 404s (Layoutnotfound).

... , - . , ( ). IIS 200 , web.config ( ) . , . - .

http://learn.iis.net/page.aspx/267/how-to-use-http-detailed-errors-in-iis-70/ http://www.iis.net/ConfigReference/system.webServer/ httpErrors http://msdn.microsoft.com/en-us/library/ms689487(v=VS.90).aspx

You can also change the RequestErrors.UseServerSideRedirect parameter to true to provide better HTTP responses without redirecting.

0
source

All Articles