Search code examples
mongodbelmah

How to configure custom collection name for ELMAH MongoDB?


The default collection name for storing errors that is automatically created is "Elmah". Is there any way to specify custom collection name?

The reason of it is to have 2 or more applications sharing the same Mongo database but not messing all errors inside single collection (all apps will point to "Elmah" collection).

I expect to add an additional parameter in web.config, somewhere here for example:

<errorLog type="Elmah.MongoErrorLog, Elmah.MongoDB.Driver2, Version=2.1.0.0,
Culture=neutral, PublicKeyToken=null" connecionStringName="ELMAH.MongoDB" 
maxSize="10485760" maxDocuments="10000">

Solution

  • Found solution while decompiling Elmah.MongoDB.Driver2. Code uses combination of 'Elmah' string + application name setting. So the solution will be to add application name into errorLog node of Elmah MongoDB configuration in web.config that I mentioned above:

    <errorLog type="Elmah.MongoErrorLog, Elmah.MongoDB.Driver2, Version=2.1.0.0,
    Culture=neutral, PublicKeyToken=null" connecionStringName="ELMAH.MongoDB" 
    maxSize="10485760" maxDocuments="10000" applicationName="your_custom_name">