Search code examples
asp.net-mvcazure-storageelmah.mvc

How to use Azure storage for elmah logs instead of elmah logs in SQL Server database


Currently in my project, I am logging exceptions by using elmah in a separate table in SQL Server. Is it possible to store these elmah exceptions in Azure storage only, not in SQL Server? Since I do not want to log errors in my database.

//web.config     
<elmah>
    <security allowRemoteAccess="1" />
    <errorLog type="Elmah.SqlErrorLog, Elmah" 
              connectionStringName="DatabaseConnectionStringName" />
</elmah>    

Currently in my web.config, I configure for elmah logs in SQL Server.

Set allowRemoteAccess = 1 and added errorlog type as Elmah.SqlErrorLog. Can anyone help?

Thanks in advance.


Solution

  • It is possible, we can store elmah exceptions in Azure table storage.

    We need to use this package: Elmah.AzureTableStorage.

    We can install this via VS Package Manager:Install-Package Elmah.AzureTableStorage -Version 1.0.0.

    In web.config, we can set as below:

    <errorLog type="Elmah.AzureTableStorage.AzureTableStorageErrorLog, Elmah.AzureTableStorage"
    connectionStringName="ElmahAzureTableStorage" />
    

    I have tested and the screenshot of my log in table storage for your reference:

    enter image description here

    More information for your reference:

    GitHub: Elmah.AzureTableStorage

    ELMAH on Azure Table Storage