Pergunta

We have a Webservice that has been logging Elmah errors as XML files into a folder. This webservice application has pure ASMX webservices and ASPX webservices.

We now have a requirement to log these errors to different folders based on whether the error is occurring in the pure ASMX webservices or the ASPX webservices. The ASMX webservices log errors using a SoapExtension whereas the ASPX webservices log errors using custom error logging.

Is logging to different folders supported in Elmah?

Global.asax.cs

protected void Application_BeginRequest(Object sender, EventArgs e)
        {
            var xmlFileErrorLog = (XmlFileErrorLog)ErrorLog.GetDefault(HttpContext.Current);
            elmahLogPathField.SetValue(xmlFileErrorLog, elmahDirectory);
        }

protected void ErrorLog_Filtering(object sender, ExceptionFilterEventArgs e)
        {
            if (loggingEnabledDocumentManagement == "0")
            {
                e.Dismiss();
                return;
            }
        }
Foi útil?

Solução

Based on my experience and a review of the Elmah docs at Elmah (code.google.com) I do not believe this is possible with one instance of Elmah. All the documentation talks about choosing the output location.

It seems the only solution is to wrap calls to Elmah with a method that redirects to two different Elmah loggers.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top