顯示具有 Elmah 標籤的文章。 顯示所有文章
顯示具有 Elmah 標籤的文章。 顯示所有文章

2023年2月23日 星期四

[研究][ASP.NET]無法從組件 'Elmah' 載入類型 'Elmah.ErrorLogModule'。

[研究][ASP.NET]無法從組件 'Elmah' 載入類型 'Elmah.ErrorLogModule'。

2023-03-02

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C#

********************************************************************************

********************************************************************************

檢查發現 elmah.corelibrary.1.2.2 -> elmah.corelibrary.2.0.0-alpha001

降版本後正常。

有可能因為 alpha 版,bug還很多;有可能 1.2.2 到 2.0.0 版本改變太大。

********************************************************************************

(正確性待確認)

升級 elmah.corelibrary.1.2.2 為 elmah.corelibrary.2.0.0-alpha001,出現 無法從組件 'Elmah' 載入類型 'Elmah.ErrorLogModule',如何處理?

ChatGPT::

在將 Elmah.CoreLibrary 從版本 1.2.2 升級到 2.0.0-alpha001 時,出現 "無法從組件 'Elmah' 載入類型 'Elmah.ErrorLogModule'" 的錯誤,可能是因為 Elmah.ErrorLogModule 類已經被移動到了不同的名稱空間中。在 Elmah.CoreLibrary 2.0.0-alpha001 中,Elmah.ErrorLogModule 類被移動到了 ElmahCore 名稱空間中。

要解決此問題,您需要更新您的應用程式以使用新的名稱空間。請按照以下步驟進行操作:

打開您的應用程式並導航到 Web.config 檔案。

在 Web.config 檔案中找到包含 ErrorLogModule 的模組的設置。通常,此設置在 <system.webServer> 元素中。

將 type 屬性的值從 Elmah.ErrorLogModule 更新為 ElmahCore.ErrorLogModule。

保存您的更改,重新啟動應用程式,並測試它是否正常運行。

如果您仍然遇到問題,請確認您已經安裝了 Elmah.CoreLibrary 2.0.0-alpha001,並且已經在應用程式中更新了相關的引用。如果問題仍然存在,您可以查看 Elmah.CoreLibrary 2.0.0-alpha001 的官方文檔,或者向開發人員或其他技術支援人員尋求幫助。

(完)


2022年5月28日 星期六

[研究][ASP.NET]ELMAH 1.2 SP2 Web.Config 範例

[研究][ASP.NET]ELMAH 1.2 SP2 Web.Config 範例

2022-05-27

ELMAH - Wikipedia
https://en.wikipedia.org/wiki/ELMAH
ELMAH是用於ASP.NET Web服務的開源調試工具。當添加到機器上正在運行的Web應用程序中時,引發的異常將觸發ELMAH工具中的事件處理程序。這些事件處理程序可以包括日誌記錄到各種數據庫後端,可以從Web門戶查看的日誌記錄,以及發送通知電子郵件,推文和RSS文章以向管理員建議問題。

官方網站
https://elmah.github.io/


ELMAH-1.2-sp2-sample-web.config
來源:https://code.google.com/archive/p/elmah/downloads

xxxxx
<?xml version="1.0" encoding="utf-8"?>
<configuration>

    <configSections>
        <sectionGroup name="elmah">
            <!-- NOTE! If you are using ASP.NET 1.x then remove the
                 requirePermission="false" attribute from the section
                 elements below as those are only needed for
                 partially trusted applications in ASP.NET 2.0 -->
            <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" />
            <section name="errorTweet" requirePermission="false" type="Elmah.ErrorTweetSectionHandler, Elmah" />
        </sectionGroup>
    </configSections>

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

        <!--
            Use to log errors to Microsoft SQL Server 2000 or later
            using ASP.NET 2.0. Set value of connectionStringName attribute
            to the name of the connection string settings to use from
            the <connectionStrings> section.
        
        <errorLog type="Elmah.SqlErrorLog, Elmah" 
            connectionStringName="..." />
        -->

        <!--
            Use to log errors to Microsoft SQL Server 2000 or later
            using ASP.NET 1.x and adjust the value of connectionString 
            attribute to your settings.

        <errorLog type="Elmah.SqlErrorLog, Elmah" 
            connectionString="Data Source=.;Initial Catalog=ELMAH;Trusted_Connection=True" />
        -->

        <!--
            Use to log errors to MySQL 5.0+. Set value of 
            connectionStringName attribute to the name of the connection 
            string settings to use from the <connectionStrings> section.

        <errorLog type="Elmah.MySqlErrorLog, Elmah" 
            connectionString="..." />
        -->

     <!--
             Use to log errors to a SQL Server Compact 4 database file 
             (requires .NET 3.5 SP1). Set value of connectionStringName 
             attribute to the name of the connection string settings to use 
             from the <connectionStrings> section.
    
          <errorLog type="Elmah.SqlServerCompactErrorLog, Elmah" connectionStringName="..." />

             The format of the connection string should be as follows:
    
          <connectionStrings>
            <add name="..." connectionString="data source=[path to the database file]" />
          </connectionStrings>
    
            Replace the content of the brackets with a file path, for 
            example:
    
          data source=C:\Elmah.sdf
    
             If the database file doesn't exist it is created automatically.
             You can also place the file in the App_Data folder, by using 
             the |DataDirectory| macro:
    
          <connectionStrings>
             <add name="..." connectionString="data source=|DataDirectory|\Elmah.sdf" />
          </connectionStrings>

      -->

      <!--
            Use to log errors to SQLite using ASP.NET 2.0. Set value of 
            connectionStringName attribute to the name of the connection 
            string settings to use from the <connectionStrings> section.
            
        <errorLog type="Elmah.SQLiteErrorLog, Elmah" connectionStringName="..." />
        
            The format of the connection string should be as follows:
            
        <connectionStrings>
          <add name="..." connectionString="data source=[path to the database file]" />
        </connectionStrings>
            
            Replace the content of the brackets with a file path, 
            for example:
            
        data source=C:\Elmah.db
            
            If the database file doesn't exist it is created automatically.
            To specify a path relative to and below the application root, 
            start with the root operator (~) followed by a forward slash 
            (/), as it is common in ASP.NET applications. For example:
            
        data source=~/App_Data/Error.db
        -->

        <!--
            Use to log errors into separate XML files that are stored on 
            disk at the path specified in the logPath attribute.

        <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="..." />
        -->

        <!--
            Use to log errors to Oracle using ASP.NET 2.0. Set value of 
            connectionStringName attribute to the name of the connection 
            string settings to use from the <connectionStrings> section.
        
            The schemaOwner parameter is *optional*. Use this if the owner 
            of the ELMAH package (pkg_elmah$error) is not the same user that 
            you are using to connect to the database.
            
        <errorLog type="Elmah.OracleErrorLog, Elmah" 
            schemaOwner="xxx" />
            connectionStringName="..." />
        -->

        <!--
            Use to log errors to Oracle using ASP.NET 1.1 and adjust the 
            value of connectionString attribute to your settings.

            The schemaOwner parameter is *optional*. Use this if the owner 
            of the ELMAH package (pkg_elmah$error) is not the same user that 
            you are using to connect to the database.

        <errorLog type="Elmah.OracleErrorLog, Elmah" 
            schemaOwner="xxx" />
            connectionString="Data Source=xxxx;User ID=username;Password=password" />
        -->

        <!--
            Use to log errors to Microsoft Access using ASP.NET 1.x and 
            adjust the value of connectionString attribute to your settings.
            Use Elmah.mdb as your database.

        <errorLog type="Elmah.AccessErrorLog, Elmah" 
            connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|Elmah.mdb" />
        -->

        <!--
            Use to log errors to Microsoft Access using ASP.NET 2.0. Set 
            value of connectionStringName attribute to the name of the 
            connection string settings to use from the <connectionStrings> 
            section. Use Elmah.mdb as your database.
        
        <errorLog type="Elmah.AccessErrorLog, Elmah" 
            connectionStringName="..." />
        -->
    
    <!--
            Use to log errors to PostgresSQL using ASP.NET 2.0. Set value of 
            connectionString to a valid Npgsql connection string.
        
        <errorLog type="Elmah.PgsqlErrorLog, Elmah" 
            connectionString="Server=...;Port=...;Database=...;User Id=...;Password=...;" />
        -->

        <!--
            Use to send error reports by e-mail and adjust the attributes
            according to settings desired. Note that only the from and
            to attributes are required. The rest are optional and may
            be removed. If the SMTP server does not require authentication,
            you MUST remove the userName and password attributes or
            set them to empty values (resulting in zero-length strings).
            If you are using ELMAH compiled for .NET Framework 1.x, then
            the to attribute may contain multiple recipient addresses,
            each of which must be delimited by a semi-colon (;). If you are 
            using ELMAH compiled for .NET Framework 2.0 or later, then the
            to attribute may contain multiple recipient addresses,
            each of which must be delimited by a comma (,).

        <errorMail 
            from="elmah@example.com" 
            to="admin@example.com" 
            subject="..."
            priority="Low|Normal|High"
            async="true|false"
            smtpPort="25"
            smtpServer="smtp.example.com" 
            useSsl="true|false"
            userName="johndoe"
            password="secret" 
            noYsod="true|false" />
        -->

        <!--
            Use to send short error messages to a Twitter account.
        <errorTweet 
            userName="johndoe" 
            password="secret" />
        -->

        <!--
            Use to prevent errors from being mailed or logged based on
            assertions. An assertion evaluates the current context, 
            resulting in a Boolean outcome. An error is filtered if the 
            assertion results in true. For a more detailed explanation, see:
            
            http://code.google.com/p/elmah/wiki/ErrorFiltering
            
            The example below will filter errors when any of the
            following conditions occur:
            
            - The status code is set to 404 
            - The root/base cause is System.IO.FileNotFoundException
            - The root/base cause is System.Web.HttpRequestValidationException
            - The user agent making the request identifies itself as "crawler"
            - The request is from the local machine
            
            The assertion below is expressed as a JScript expression and is 
            the most generic and simplest of the assertions to use if you 
            are familiar with the JavaScript language. It can work in Medium 
            and Full trust environments.
            
            NOTE: For versions of ELMAH 1.2 SP1 and earlier, use the 
            undocumented `$context` instead of `$` in the expression below 
            to workaround a bug when the expression is evaluated under full 
            trust environments. See issue #278[1] for more details.            
            
            [1] http://code.google.com/p/elmah/issues/detail?id=278

        <errorFilter>
            <test>
                <jscript>
                    <expression>
                    <![CDATA[
                    // @assembly mscorlib
                    // @assembly System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
                    // @import System.IO
                    // @import System.Web

                    $.HttpStatusCode == 404
                    || $.BaseException instanceof FileNotFoundException 
                    || $.BaseException instanceof HttpRequestValidationException
                    /* Using RegExp below (see http://msdn.microsoft.com/en-us/library/h6e2eb7w.aspx) */
                    || $.Context.Request.UserAgent.match(/crawler/i)                      
                    || $.Context.Request.ServerVariables['REMOTE_ADDR'] == '127.0.0.1' // IPv4 only
                    ]]>
                    </expression>
                </jscript>
            </test>
        </errorFilter>
        -->

    </elmah>

    <system.web>

        <httpModules>
            
            <!-- 
                Uncomment the entry below if all of the following are true: 
                1) you are using wildcard mapping in IIS 5.x
                2) you are not using .NET 1.0
                3) you are experiencing HTTP 404 errors when trying to view
                   elmah.axd or elmah.axd/detail?id=* etc
            -->
            <!--<add name="FixIIS5xWildcardMapping" type="Elmah.FixIIS5xWildcardMappingModule, Elmah" />-->

            <!-- 
                Uncomment the entry below if you are using MS AJAX v1.0.x.x
                and want to capture errors during Partial Postbacks
                NB This is not required for the version of AJAX shipped with 
                .NET Framework v3.5!
            -->
            <!--<add name="MsAjaxDeltaErrorLog" type="Elmah.MsAjaxDeltaErrorLogModule, Elmah" />-->

            <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
        
            <!-- 
                Uncomment the entries below if error mail reporting and 
                filtering is desired.
            -->
            
            <!--<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />-->
            <!--<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />-->
            <!--<add name="ErrorTweet" type="Elmah.ErrorTweetModule, Elmah" />-->

        </httpModules>
        
    </system.web>

    <!-- 
        The <system.webServer> section is required for running ELMAH under 
        Internet Information Services (IIS) 7. It is not necessary for 
        previous version of IIS.
        
        In general, it would be best to include it for all .NET Framework 
        2.0 and above configurations in order to have a more portable 
        solution between various versions of IIS.

        IIS 5.x, IIS 6 require the modules and handlers to be declared in 
        <system.web> whereas IIS 7 needs them declared here and complains if 
        they are in fact declared in <system.web>. Fortunately, the
        <validation validateIntegratedModeConfiguration="false" /> entry 
        tells IIS 7 not to worry about the modules and handlers declared in 
        <system.web>.
        
        If you only ever want to use IIS 7, then do the following:
        
        1. Remove handlers and modules from <system.web>
        2. Remove the <validation validateIntegratedModeConfiguration="false" /> element
    -->

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

    <!-- 
        This entry provides the UI for the error log at elmah.axd below the 
        application path. For example, if your domain is www.example.com and 
        your application is at the root, then you can view the error log by
        visiting the following URL:
                
        http://www.example.com/elmah.axd

        IMPORTANT! To secure this location, consult the following notes:
                
        http://code.google.com/p/elmah/wiki/SecuringErrorLogPages
    -->

    <location path="elmah.axd">  
        <system.web>
            <httpHandlers>
                <add verb="POST,GET,HEAD" 
                     path="elmah.axd" 
                     type="Elmah.ErrorLogPageFactory, Elmah" />
            </httpHandlers>
            <!-- 
                The following entry denies unauthenticated users access to 
                the path from where ELMAH's handlers are accessible. If you 
                have role-based security implemented, you SHOULD consider 
                instead allowing access by a particular role (for example, 
                operators and administrators).
        
                IMPORTANT: If you change the path of the handler then you 
                MUST also change the path in the containing location tag 
                to be the same.

                For more information, see:
                http://code.google.com/p/elmah/wiki/SecuringErrorLogPages
            -->
            <authorization>
                <deny users="?" />  
            </authorization>  
        </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>


下面,errorFilter過濾404錯誤

https://code.google.com/archive/p/elmah/wikis/ErrorFiltering.wiki

<elmah> 
    ... 
    <errorFilter> 
        <test> 
            <equal binding="HttpStatusCode" value="404" type="Int32" /> 
        </test> 
    </errorFilter> 
</elmah>

errorFilter範例
https://elmah.github.io/a/error-filtering/
https://elmah.github.io/a/error-filtering/examples/

留做參考。

(完)


2022年4月14日 星期四

[研究][ASP.NET]Elmah寄信通知「資料庫...的交易記錄已滿,因為發生 'LOG_BACKUP'」

[研究][ASP.NET]Elmah寄信通知「資料庫...的交易記錄已滿,因為發生 'LOG_BACKUP'」

2022-04-14

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C# + Elmah + SQL Server 2019 


檢查 DB 主機上 SQL Server 的資料庫檔案 .mdf 不大,.ldf 非常大,是 .mdf 的數十倍,D: 磁碟空間剩下不到 10 MB,幾乎用光了。
.mdf 是 SQL Server Database Primary Data File
.ldf 是 SQL Server Database Transaction Log File


xxxxx.aspx.cs

catch (Exception)
{
    throw;		<=== 這行
}

(完)

相關

[研究] SQL Server 資料庫 的交易紀錄已滿,因為發生 'LOG_BACKUP'。

[研究] 資料庫 'xxx' 的交易記錄已滿,因為發生 'LOG_BACKUP'。

[研究] SQL Server 2016 刪除 .ldf 檔案

[研究]檢視 SQL Server Database Transaction Log File 資料庫交易記錄檔 (.ldf) 內容

[研究][ASP.NET]Elmah寄信通知「資料庫...的交易記錄已滿,因為發生 'LOG_BACKUP'」https://shaurong.blogspot.com/2022/04/aspnetelmah-logbackup.html

[研究]檢視 SQL Server Database Transaction Log File 資料庫交易記錄檔 (.ldf) 內容https://shaurong.blogspot.com/2022/04/sql-server-database-transaction-log.html

[研究]縮小 SQL Server Database Transaction Log File 資料庫交易記錄檔 (.ldf) 大小https://shaurong.blogspot.com/2022/04/sql-server-database-transaction-log_14.html



2020年8月27日 星期四

[研究][ASP.NET][C#] ELMAH - 錯誤通知信設定

[研究][ASP.NET][C#] ELMAH - 錯誤通知信設定

[研究][C#] ELMAH - ASP.NET錯誤記錄模組 (Error Logging Modules and Handlers)(NuGet安裝)

2022-04-16

官方網站

https://elmah.github.io/

https://code.google.com/p/elmah/downloads/list

https://www.nuget.org/packages/elmah/1.2.2

環境:Windows Server 2019 + Visual Studio 2019



Web.Config 內容
找到  <location path="elmah.axd" inheritInChildApplications="false"> 之行
上方的 <elmah> </elmah> 區塊,進行修改。
********************************************************************************
<?xml version="1.0" encoding="utf-8"?>

<!--
  如需如何設定 ASP.NET 應用程式的詳細資訊,請前往
  https://go.microsoft.com/fwlink/?LinkId=169433
  -->
<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.7.2" />
    <httpRuntime targetFramework="4.7.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.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
    </compilers>
  </system.codedom>

  <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>
    <!--<errorMail from="test@test.com" to="test@test.com" subject="Application Exception" async="false" smtpPort="25" smtpServer="***" userName="***" password="***">    </errorMail>-->

    <!--<errorMail subject="【XX網站】error" from="from@test.com" to="to1@test.com, to2@test.com" priority="High" async="true" smtpPort="0" smtpServer="localhost"  />-->

    <errorMail subject="【XX網站】{0}" from="from@test.com" to="to1@test.com, to2@test.com" priority="High" async="true" smtpPort="0" smtpServer="localhost"  />
    <!--
        See http://code.google.com/p/elmah/wiki/SecuringErrorLogPages for 
        more information on remote access and securing ELMAH.
    -->
    <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>
      <!-- 
        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="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
      </handlers>
    </system.webServer>
  </location>
</configuration>

********************************************************************************
{0} 是 Elmah errorMail 預設錯誤主旨

Default.axpx

<%@ Page Language="C#" AutoEventWireup="true" 
    CodeBehind="Default.aspx.cs" Inherits="WebApplication1.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
         <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br />
        <asp:Button ID="Button1" runat="server" Text="Button" 
            OnClick="Button1_Click" /><br />
        <asp:Label ID="Label1" runat="server"></asp:Label>
    </form>
</body>
</html>


Default.aspx.cs

using System;

namespace WebApplication1
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Int32.TryParse(TextBox1.Text, out int a);
            Int32.TryParse(TextBox2.Text, out int b);
            Label1.Text = (a / b).ToString();
        }
    }
}

第1個欄位隨便輸入整數,第2個欄位輸入0,按下按鈕,執行結果



(完)

2017年2月7日 星期二

[研究][C#][ASP.NET] ELMAH 簡易試用 (Win 2016 + IIS + WebForm)

[研究][C#][ASP.NET] ELMAH 簡易試用 (Win 2016 + IIS + WebForm)

2017-02-07
2022-04-04更新

ELMAH  => Error Logging Modules and Handlers
環境:Windows Server 2016 + IIS Web Server
工具:Visual Studio 2015 with Update 3











(下圖) 在網站的網址後面加上 elmah.axd 就可以看到一些沒有攔截到的 例外 (Exception) 資訊
,預設只有本機可以看到 Elmah Error Log




(下圖) 預設遠端會看到 403 - 禁止:拒絕存取

想讓遠端檢視,請看這篇

[研究][C#][ASP.NET] ELMAH 簡易試用-遠端檢視 (Win 2016)
http://shaurong.blogspot.com/2017/02/caspnet-elmah-win-2016.html

********************************************************************************

2022-04-04
不需要自己寫個除0程式去測試,使用下面網址就會產生一個 Exception 測試 Elmah
http://localhost/elmah.axd/test

使用 ELMAH 記錄錯誤的詳細資料 (C#) | Microsoft Docs

(完)

相關

[研究][C#][ASP.NET] ELMAH 簡易試用 (Win 2016 + IIS + WebForm)
http://shaurong.blogspot.com/2017/02/caspnet-elmah-win-2016-iis-webform.html

[研究][C#][ASP.NET] ELMAH 簡易試用-遠端檢視 (Win 2016)
http://shaurong.blogspot.com/2017/02/caspnet-elmah-win-2016.html

[研究][C#] ELMAH - ASP.NET錯誤記錄模組 (Error Logging Modules and Handlers)(NuGet安裝)
http://shaurong.blogspot.com/2016/04/c-elmah-aspnet-error-logging-modules.html