Regarding GetErrorCount

55 views
Skip to first unread message

Sampath Kumar

unread,
Apr 30, 2012, 9:13:35 AM4/30/12
to ELMAH
Hi Team,

I have been using GetErrorCount method of ErrorLogDataSourceAdapter
class to get the total error count. There is a small discrepancy in
the count returned by the method when I have compared it by counting
number of rows in elmah_error table from sqlserver. Can someone please
let me know if there is any default filter applied to
ErrorLogDataSourceAdapter.

Thanks,
Sampath

James_2JS

unread,
Apr 30, 2012, 9:24:07 AM4/30/12
to el...@googlegroups.com
Hi Sampath,

Try running this against your SQL Server database:

SELECT [Application], Count(*)
FROM [ELMAH_Error]
Group By [Application]

Does that shed some light on the difference?

Cheers,

James

Sampath Kumar

unread,
May 2, 2012, 1:36:20 AM5/2/12
to ELMAH
As suggested offline, following is the config section details I have
used for elmah

<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" />
<section name="errorTweet" requirePermission="false"
type="Elmah.ErrorTweetSectionHandler, Elmah" />
</sectionGroup>


<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
</httpModules>

<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd"
type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>

---------------------------------------------------------------------------

The following is the result of the query u have asked me to run on my
database.

SELECT [Application], Count(*)
FROM [ELMAH_Error]
Group By [Application]

Application (No column name)
---------------------------------------------------------------------------
/ 118
/lm/w3svc/1/ROOT/ShellMOC 6


------------------------------------------------------------------------------------------------------

Regards,
Sampath

****************************************

James_2JS

unread,
May 2, 2012, 6:47:25 AM5/2/12
to el...@googlegroups.com
Can you also post your <elmah> section please?


On Monday, April 30, 2012 2:13:35 PM UTC+1, Sampath Kumar wrote:

Sampath Kumar

unread,
May 2, 2012, 6:50:45 AM5/2/12
to ELMAH
Sorry, forgot to include this..
***************************************************
<elmah>
<security allowRemoteAccess="0" />
<!--
Use to log errors to Microsoft SQL Server 2000 or 2005
using ASP.NET 2.0. Set value of connectionStringName
attribute
to the name of the connection string settings to use from
the <connectionStrings> section.
-->
<errorLog type="Elmah.SqlErrorLog, Elmah"
connectionStringName="ElmahDB" />
<!--
Use to send error reports by e-mail and adjust the
attributes
according to settings desired. Note that only the from and
to attributes are required. The rest are optional and may
be removed. If the SMTP server does not require
authentication,
you MUST remove the userName and password attributes or
set them to empty values (resulting in zero-length
strings).
If you are using ELMAH compiled for .NET Framework 1.x,
then
the to attribute may contain multiple recipient addresses,
each of which must be delimited by a semi-colon(;). If you
are
using ELMAH compiled for .NET Framework 2.0 or later, then
the
to attribute may contain multiple recipient addresses,
each of which must be delimited by a comma (,).
-->
<errorMail from="" to="" subject="" priority="Low" async="false"
smtpPort="25" smtpServer="" useSsl="true" noYsod="false" />
</elmah>

------------
Regards,
Sampath

**********************************************

James_2JS

unread,
May 2, 2012, 8:00:51 AM5/2/12
to el...@googlegroups.com
Hi Sampath,

As you can see from the results of the query, ELMAH has logged errors under two different application names.
The SqlServerErrorLog (and others) allows this functionality so that you can have one central SQL Server logging all unhandled exceptions for a variety of applications whilst distinguishing between them all.
The application name can be set by setting an attribute on the <errorLog> element as follows:

<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="ElmahDB" applicationName="Your Application Name" />  

If this attribute is not set, ELMAH tries to infer it as can be seen by the following code:

In your case, I'm not entirely sure why ELMAH has inferred two different application names!

However, it's easy to remedy the situation by:

1) Setting the application name in web.config (as per above)
2) Running an update script on your SQL database to set the application name for your existing errors.

Once you've done this, everything should work as you expect!

Hope this helps.
Cheers,

James
Reply all
Reply to author
Forward
0 new messages