Error-mail med Health monitor
Ett riktigt bra tips av Mads Kristensen, som förklarar hur man kan konfigurera health monotor i .NET så den skickar mail, när ett oväntat fel har uppstått i applikationen. Läs mer på MSDN.
Inställningarna i Web.config ser ut så här:
<?xml version="1.0"?>
<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<compilation debug="false" />
<trace enabled="true" localOnly="false" />
<healthMonitoring enabled="true">
<providers>
<add name="EmailProvider"
type="System.Web.Management.SimpleMailWebEventProvider"
from="you@domain.com"
to="you@domain.com"
subjectPrefix="Error: "
buffer="true"
bufferMode="Notification" />
</providers>
<rules>
<add provider="EmailProvider" name="All App Events" eventName="All Errors" />
</rules>
</healthMonitoring>
</system.web>
<system.net>
<mailSettings>
<smtp from="you@domain.com">
<network host="smtp.domain.com" />
</smtp>
</mailSettings>
</system.net>
</configuration>
<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<compilation debug="false" />
<trace enabled="true" localOnly="false" />
<healthMonitoring enabled="true">
<providers>
<add name="EmailProvider"
type="System.Web.Management.SimpleMailWebEventProvider"
from="you@domain.com"
to="you@domain.com"
subjectPrefix="Error: "
buffer="true"
bufferMode="Notification" />
</providers>
<rules>
<add provider="EmailProvider" name="All App Events" eventName="All Errors" />
</rules>
</healthMonitoring>
</system.web>
<system.net>
<mailSettings>
<smtp from="you@domain.com">
<network host="smtp.domain.com" />
</smtp>
</mailSettings>
</system.net>
</configuration>
Tags