I configured HealthMonitoring in my web application to log all exceptions in the database.
But, when I gracefully handle some exception by showing a nice message to the user, they are not logged in the database. If I something like Throw ex, the standard error page is be displayed and the error is not gracefully handled.
Is there something else I could add at the end of my error handler to tell the system to also log this error?
here an code sample:
Dim errorText As String = "Doing Something"
Try
'Do Something
Catch ex As Exception
DataActionError.Text = String.Format("There was a problem {0}. ", errorText)
DataActionError.Visible = True
'add something here?
End Try
and the healthMonitoring section of my web.config :
<healthMonitoring enabled="true">
<eventMappings>
<clear />
<add name="All Errors"
type="System.Web.Management.WebBaseErrorEvent"
startEventCode="0"
endEventCode="2147483647" />
</eventMappings>
<providers>
<clear />
<add connectionStringName="MyConnectionString"
maxEventDetailsLength="1073741823"
buffer="false"
name="SqlWebEventProvider"
type="System.Web.Management.SqlWebEventProvider" />
</providers>
<rules>
<clear />
<add name="All Errors To Database"
eventName="All Errors"
provider="SqlWebEventProvider"
profile="Default"
minInstances="1" maxLimit="Infinite"
minInterval="00:00:00" />
</rules>
</healthMonitoring>
You can raise your own events which would then be consumed by the providers.
You can’t raise a
WebBaseErrorEventyourself, but you can create a custom web event and tweak your configuration to capture it too.See
http://msdn.microsoft.com/en-us/library/ms998306
http://msdn.microsoft.com/en-us/library/ms227980.aspx