Wednesday, 11 September 2013

Using Elmah with ServiceStack

Using Elmah with ServiceStack

I'm trying to use Elmah with ServiceStack but am encountering the
following problems:
When I go to /elmah.axd on my site it returns a 404 rather than showing
the Elmah logging page.
Emails dont seem to be sending
Here is the code:
I have set the LogManager.LogFactory in the constructor of AppHost:
public AppHost() //Tell ServiceStack the name and where to find your web
services
: base("StarterTemplate ASP.NET Host", typeof(HomeService).Assembly)
{
LogManager.LogFactory = new ElmahLogFactory(new NLogFactory());
}
In web.config I have the following sections declared:
<configSections>
<sectionGroup name="elmah">
<section name="security" requirePermission="false"
type="Elmah.SecuritySectionHandler, Elmah" />
<section name="errorLog" requirePermission="false"
type="Elmah.ErrorLogSectionHandler, Elmah" />
<section name="errorMail" requirePermission="false"
type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" requirePermission="false"
type="Elmah.ErrorFilterSectionHandler, Elmah" />
</sectionGroup>
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpHandlers>
<add path="*"
type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory,
ServiceStack" verb="*" />
<add verb="POST,GET,HEAD" path="elmah.axd"
type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
</httpModules>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add path="*" name="ServiceStack.Factory"
type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory,
ServiceStack" verb="*" preCondition="integratedMode"
resourceType="Unspecified" allowPathInfo="true" />
<add name="Elmah" path="elmah.axd" verb="POST,GET,HEAD"
type="Elmah.ErrorLogPageFactory, Elmah"
preCondition="integratedMode" />
</handlers>
<modules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"
preCondition="managedHandler" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah"
preCondition="managedHandler" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah"
preCondition="managedHandler" />
</modules>
</system.webServer>
<location path="elmah.axd">
<system.webServer>
<handlers>
<remove name="ServiceStack.Factory" />
</handlers>
</system.webServer>
</location>
<elmah>
<security allowRemoteAccess="true" />
<errorLog type="Elmah.XmlFileErrorLog, Elmah"
logPath="~/App_Data/Elmah" />
<errorMail from="elmaherror@domain.com" to="myemail@domain.com"
async="false" smtpServer="192.168.0.5" smtpPort="25" userName=""
password="" />
</elmah>
The SMTPServer and Emails are all configured correctly and I can see the
error XML files in App_Data/Elmah so error's are being logged..

No comments:

Post a Comment