MongoDB Web界面上的ELMAH抛出异常

Mar*_*red 5 error-handling logging elmah mongodb

MongoDB nuget包上使用ELMAH 配置日志到MongoDB后,它成功登录到MongoDB集合,但在尝试访问Web界面时,它给出了以下异常:

命令'create'失败:集合'collectionname'已经存在(响应:{"note":"autoIndexId选项已弃用,将在以后的版本中删除","ok":0.0,"errmsg":"一个集合'collectionname'已存在","code":48,"codeName":"NamespaceExists"})

我不知道为什么每次尝试为elmah创建web配置配置集合时:

 <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>
Run Code Online (Sandbox Code Playgroud)

小智 0

此错误是由 MongoDB 3.2 及更高版本的 decrepted 函数(创建新集合时与索引相关)引起的,请尝试使用 3.0 mongos 版本或更改 mongo 的驱动程序。我在 Visual Studio nuget 包控制台中使用此包Install-Package elmah.mongodb,在 c#.net 中使用 mongo 3.0 版本,并且运行完美。

我希望它能帮助你!祝你好运。