Skip to content

FreedomMercenary/elmah-mongodb

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Elmah-MongoDB

See: Elmah Error Logging with MongoDB Official Driver

Overview

ELMAH (Error Logging Modules and Handlers) is an application-wide error logging facility that is completely pluggable. It can be dynamically added to a running ASP.NET web application, or even all ASP.NET web applications on a machine, without any need for re-compilation or re-deployment.

This provider enables MongoDB to be used as the back-end storage via the Official 10gen provider.

Usage

The easiest way to add this to a project is via the elmah.mongodb NuGET package which will add the required assemblies to your project.

The provider supports multiple per-application collections within a single database and will automatically create a MongoDB Capped Collection called 'Elmah' if the application name is not set or will use Elmah-ApplicationName if it is.

The size of the MongoDB collection can be controlled by setting the maxSize (bytes) and maxDocuments properties. By default a 100mb collection is used (with no document limit).

Configuration

Here is an example configuration:

<elmah>
  <errorLog type="Elmah.MongoErrorLog, Elmah.MongoDB" connectionStringName="elmah-mongodb" maxSize="10485760" maxDocuments="10000"/>
</elmah>
<connectionStrings>
  <add name="elmah-mongodb" connectionString="mongodb://localhost/elmah?w=0"/>
</connectionStrings>

Azure Cosmos Support

Azure Cosmos is not 100% API compatible with MongoDB and as such requires some modifications to the behavior of this library in order to be compatible.

These issues are known as of 6/14/2020:

  • Capped collections are not supported
  • $natural is not supported for sorting

In order to work around these issues, use the following additional attributes to disable capped collection on collection creation and use the primary key for sorting:

<elmah>
  <errorLog type="Elmah.MongoErrorLog, Elmah.MongoDB" connectionStringName="elmah-mongodb" maxSize="10485760" maxDocuments="10000" sortKey="_id" useCappedCollection="false"/>
</elmah>

Releases

No releases published

Packages

No packages published

Languages

  • C# 88.9%
  • CSS 4.5%
  • HTML 3.2%
  • JavaScript 2.3%
  • Other 1.1%