ELMAH on MongoDB web interface throw exception

Viewed 169

after configure logs to MongoDB using ELMAH on MongoDB nuget package it successfully log to MongoDB collection but when trying to access the Web interface it gives me the following exception:

Command 'create' failed: a collection 'collectionname' already exists (response: { "note" : "the autoIndexId option is deprecated and will be removed in a future release", "ok" : 0.0, "errmsg" : "a collection 'collectionname' already exists", "code" : 48, "codeName" : "NamespaceExists" })

i don't know why each time it try to create the collection the web config configuration for elmah:

 <sectionGroup name="elmah">
      <section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
      <section name="errorLog" requirePermission="false" type="Elmah.FallbackErrorLogSectionHandler, Elmah.FallbackErrorLog" />
      <section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
      <section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
    <!--<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />-->
  </sectionGroup>

 <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules>
      <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
      <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
      <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />
    </modules>
  </system.webServer>
<elmah>


  <security allowRemoteAccess="true" />

  <errorLog type="Elmah.FallbackErrorLog, Elmah.FallbackErrorLog">
    <add type="Elmah.MongoErrorLog, Elmah.MongoDB" connectionStringName="elmah-mongodb"  />
    <add type="Elmah.XmlFileErrorLog, Elmah" logPath="C:\MyApp\logs\ElmahFallback" />
  </errorLog>
</elmah>
<location path="logs" inheritInChildApplications="false">
    <system.web>
      <httpHandlers>
        <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
      </httpHandlers>


      <authorization>
        <!--<allow roles="*" />-->
        <allow users="*" />  
      </authorization>

    </system.web>
    <system.webServer>
      <handlers>
        <add name="ELMAH" verb="POST,GET,HEAD" path="logs" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
      </handlers>
    </system.webServer>
  </location>
1 Answers

this error is by MongoDB 3.2 and up decrepted function (related by indexes when you create a new collection), try with 3.0 mongos's version or change the mongo's driver. I'm using this package Install-Package elmah.mongodb in visual studio nuget package console and mongo 3.0 version in c#.net and it's running perfectly.

I hope that it help you!!! good luck.

Related