zoukankan      html  css  js  c++  java
  • 三分钟集成elmah xml 格式日志到mvc站点

    1.通过nuget安装Elmah

    ELMAH on XML Log 会自动在web.config 文件中添加配置内容,默认不允许远程访问,日志访问路径是 Elmah.axd,不记录500错误

    2.修改配置文件

    增加500的异常记录,允许远程访问

     <elmah>
        <!--
            See http://code.google.com/p/elmah/wiki/SecuringErrorLogPages for 
            more information on remote access and securing ELMAH.
        -->
        <security allowRemoteAccess="true" />
        <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data/Elmah.Errors" />
        <errorFilter>
          <test>
            <equal binding="HttpStatusCode" value="404" type="Int32" />
            <equal binding="HttpStatusCode" value="500" type="Int32" />
          </test>
        </errorFilter>
      </elmah>

    修改访问路径

    <location path="log.axd" inheritInChildApplications="false">
        <system.web>
          <httpHandlers>
            <add verb="POST,GET,HEAD" path="log.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
          </httpHandlers>
          <!-- 
            See http://code.google.com/p/elmah/wiki/SecuringErrorLogPages for 
            more information on using ASP.NET authorization securing ELMAH.
    
          <authorization>
            <allow roles="admin" />
            <deny users="*" />  
          </authorization>
          -->
        </system.web>
        <system.webServer>
          <handlers>
            <add name="ELMAH" verb="POST,GET,HEAD" path="log.axd" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
          </handlers>
        </system.webServer>
      </location>

    在nuget上有很多ELMAH的扩展可以存储为其它格式。

  • 相关阅读:
    Node
    HTTP权威指南
    一些乱七八糟的思考积累
    有限状态机
    奇怪问题引用到其它文件夹项目文件方法
    dijkstra+堆优化
    高精度
    BUAA 1301 最短路
    阿里云服务器ECS(Centos8)下安装和配置python3.8
    Cheat Sheet
  • 原文地址:https://www.cnblogs.com/zeroes/p/ELMAH.html
Copyright © 2011-2022 走看看