简体   繁体   English

ELMAH-在生产环境中未收到电子邮件

[英]ELMAH - Email not received in production environment

I have integrated ELMAH library for logging the error. 我已经集成了ELMAH库来记录错误。 I have integrated email code for getting error list but unable to get those errors. 我已经集成了用于获取错误列表的电子邮件代码,但无法获取这些错误。 Can anyone help me for same. 谁能帮我同样的忙。 Below is my configuration code in web.config 以下是我在web.config中的配置代码

Web.config File Web.config文件

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <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" />
    </sectionGroup>
  </configSections>

  <system.web>
    <compilation debug="true" targetFramework="4.5.2" />
    <httpRuntime targetFramework="4.5.2" />
    <httpModules>
      <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
      <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
      <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
    </httpModules>
  </system.web>

  <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>

    <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/ElmahLog" />
    <errorMail from="error@devtracker.com"
     to="ankitkanojia.rs@gmail.com"
     subject="Devtracker - Error occurs"
     async="true" />

    <security allowRemoteAccess="false" />
  </elmah>


  <location path="elmah.axd" inheritInChildApplications="false">
    <system.web>
      <httpHandlers>
        <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
      </httpHandlers>     
    </system.web>
    <system.webServer>
      <handlers>
        <add name="ELMAH" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
      </handlers>
    </system.webServer>
  </location>

</configuration>

After going through your question, I've found that you just forgot to add an email setting. 处理完您的问题后,我发现您只是忘记添加电子邮件设置。 Add the below lines in your web.config. 在您的web.config中添加以下行。 Make sure to change the hostname, port, username, and password. 确保更改主机名,端口,用户名和密码。

<system.net>
    <mailSettings>
      <smtp deliveryMethod="Network">
        <network host="host address" port="12345" userName="username here" password="password here"/>
      </smtp>
    </mailSettings>
</system.net>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM