zoukankan      html  css  js  c++  java
  • ASP.NET MVC ELMAH错误日志

    工具運用得宜可說提高不少效率喔!(好工具帶我們上天堂, 壞工具帶我們住套房XD),

    所以今天就來使用elmah替我們紀錄整個網站的例外事件,

    該工具設定過程簡單明瞭,重點是'資訊豐富',實在不錯用。

     ELMAH On IIS6

    1.download elmah並在專案中加入參考

    image

    2.編輯Web.config呼叫Elmah

    <configuration>

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

    <httpHandlers> 

    <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />

    <httpModules>

    <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
     

    <system.web>只有有任何列外狀況都將導到Error.aspx

    <customErrors mode="On" defaultRedirect="~/Error">
          <error statusCode="404" redirect="~/Error"/>
          <error statusCode="500" redirect="~/Error"/>
    </customErrors>
    <configuration>導出xml檔案到相關存放路徑
    <elmah>
        <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="D:/Log_Data" />   
    </elmah>
     

    3.Configure routing(RegisterRoutes in Global.asax.cs)

     routes.IgnoreRoute( "elmah.axd" );  
     

    到這裡就算完成整個elmah的設定了,現在準備來測試搂。

    丟出NullException

    public ActionResult PersonCreate()
            {
                throw new ArgumentNullException();               
                return View();
            }

    image

    查看Log(http://server//elmah.axd)

    image

    點擊Details(擷取部分)

    image

    xml檔案

    image

    image

    資訊相當詳細完整。

  • 相关阅读:
    try catch finally return
    github结合TortoiseGit使用sshkey,无需输入账号和密码
    github上fork别人的代码之后,如何保持和原作者同步的更新
    第9章 浅度和深度复制
    9.7结构类型
    excel在msdn上的说明文档
    9.6接口和抽象类
    [LeetCode]N-Queens II
    鸟哥Linux私房菜知识汇总8至9章
    Memcahce(MC)系列(三)Memcached它PHP转让
  • 原文地址:https://www.cnblogs.com/stalwart/p/1880883.html
Copyright © 2011-2022 走看看