Monday 8 August 2016

Elmah Exception logs

  /// <summary>
        /// Created By-Salik Ram Maurya
        /// To edit inventory data
        /// </summary>
        /// <param name="itemId"></param>
        /// <returns></returns>
        public ActionResult EditInventory(int? itemId)
        {
            sbLog = new StringBuilder();
            sbLog.Append("Start of EditInventory() get method of InventoryController");
            sbLog.Append("Inventory Item Id" + itemId);

            try
            {
                if (Session["UserId"] != null)
                {
                    if (itemId > 0)
                    {
                        ViewBag.Id = itemId;
                        InventoryModel objInt = objInventory.EditInventoryData(itemId);
                        sbLog.Append("Item name:");
                        sbLog.Append(objInt.Item);
                        sbLog.Append("End of EditInventory method");
                        return View(objInt);
                    }
                    else
                    {
                        sbLog.Append("Item id is null");
                        sbLog.Append("End of EditInventory method");
                        return RedirectToAction("InventorySummary", "Inventory");
                    }
                }
                else
                {
                    return RedirectToAction("Login", "UserAccount");
                }

            }
            catch (Exception ex)
            {
                sbLog.AppendLine();
                sbLog.Append("Error: " + ex);
                ErrorLog.GetDefault(null).Log(new Error(new InvalidOperationException("Log:" + sbLog.ToString())));

                return View("Error", new HandleErrorInfo(ex, "Edit Inventory Info", "EditInventory"));
            }

        }
config file
<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>

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

  <section name="chargify" type="ChargifyNET.Configuration.ChargifyAccountRetrieverSection"/></configSections>

  <elmah>
    <security allowRemoteAccess="yes"/>
    <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="BluSavvyConnectionString"/>
    <errorMail from="salikm@chetu.com" to="salikm@chetu.com" subject="BluSavvy-TX - Exception Notification" async="true"/>

    <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

                    $.Context.Request.UserAgent.match('/*+/arterySignalR/ping')                    
                    ]]>
          </expression>
        </jscript>
      </test>
    </errorFilter>
   
  </elmah>

  <connectionStrings>
    <!--<add name="BluSavvyConnectionString" connectionString="Data Source=DATA-PROD\SQL2014;Initial Catalog=BluSavvy-TX;Persist Security Info=True;User ID=BluSavvy;Password=Blu@123" providerName="System.Data.SqlClient" />-->
    <add name="BluSavvyConnectionString" connectionString="Data Source=WEBSERVER\SQL2014;Initial Catalog=BluSavvy;Persist Security Info=True;User ID=BluSavvy;Password=Chetu@123" providerName="System.Data.SqlClient"/>
  </connectionStrings>

  <system.net>
    <mailSettings>
      <smtp deliveryMethod="Network" from="mahtabh@chetu.com">
        <specifiedPickupDirectory pickupDirectoryLocation="D:\mailroot"></specifiedPickupDirectory>
        <!--<network host="localhost" port="25" defaultCredentials="true" enableSsl="false" />-->
        <!--Uncomment for sending email of elmah exceptions-->
        <network host="mail01.chetu.com" userName="salikm@chetu.com" password="Chetu@21" port="25" defaultCredentials="false" enableSsl="true"/>
      </smtp>
    </mailSettings>
  </system.net>

  <appSettings>
    <add key="webpages:Version" value="2.0.0.0"/>
    <add key="webpages:Enabled" value="false"/>
    <add key="PreserveLoginUrl" value="true"/>
    <add key="ClientValidationEnabled" value="true"/>
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/>

    <add key="userName" value="rajukumar637@gmail.com"/>
    <add key="password" value="cabps6453c"/>
    <add key="MailServerName" value="smtp.gmail.com,587"/>
    <add key="MailFrom" value="rajukumar637@gmail.com"/>
    <add key="Host" value="smtp.gmail.com"/>
    <add key="Port" value="587"/>

    <add key="Subject" value="Password Reset Link"/>
    <add key="ReferralSubject" value="Congratulations..!! Referral is successful."/>
    <add key="Welcome" value="Welcome..!! You have successfully subscribed"/>
    <add key="Register" value="Welcome..!! You have successfully registered"/>


    <!--status of Sales-->
    <add key="DepositStatus" value="Deposited"/>
    <add key="UndepositStatus" value="Undeposited"/>
    <add key="EncryptionKey" value="MAKV2SPBNI99212"/>
    <add key="BasicPlan" value="14.99"/>
    <add key="PremiumPlan" value="29.99"/>

    <add key="elmah.mvc.disableHandler" value="false"/>
    <add key="elmah.mvc.disableHandleErrorFilter" value="false"/>
    <add key="elmah.mvc.requiresAuthentication" value="false"/>
    <add key="elmah.mvc.IgnoreDefaultRoute" value="false"/>
    <add key="elmah.mvc.allowedRoles" value="*"/>
    <add key="elmah.mvc.allowedUsers" value="*"/>
    <add key="elmah.mvc.route" value="elmah"/>
    <add key="elmah.mvc.UserAuthCaseSensitive" value="true"/>
  </appSettings>
  <system.web>
    <customErrors mode="Off">
      <error statusCode="404" redirect="~/Error.html"/>
    </customErrors>

    <compilation debug="true" targetFramework="4.5"/>
    <httpRuntime targetFramework="4.5"/>
    <authentication mode="Forms">
      <forms loginUrl="~/UserAccount/Login" timeout="5760"/>
    </authentication>
    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers"/>
        <add namespace="System.Web.Mvc"/>
        <add namespace="System.Web.Mvc.Ajax"/>
        <add namespace="System.Web.Mvc.Html"/>
        <add namespace="System.Web.Optimization"/>
        <add namespace="System.Web.Routing"/>
        <add namespace="System.Web.WebPages"/>
      </namespaces>
    </pages>
    <httpModules>
      <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
      <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah"/>
      <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah"/>
    </httpModules>
    <httpHandlers>
      <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah"/>
    </httpHandlers>

  </system.web>
  <system.webServer>


    <validation validateIntegratedModeConfiguration="false"/>
    <modules runAllManagedModulesForAllRequests="true">
      <add name="Elmah.ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler"/>
      <add name="Elmah.ErrorMail" type="Elmah.ErrorMailModule" preCondition="managedHandler"/>
      <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>

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

      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit"/>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit"/>
      <remove name="ExtensionlessUrlHandler-Integrated-4.0"/>
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0"/>
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0"/>
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0"/>
    </handlers>
    <!--<directoryBrowse enabled="true" />
        <staticContent>
            <mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
        </staticContent>-->
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

      <dependentAssembly>
        <assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246"/>
        <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246"/>
        <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-1.2.15.0" newVersion="1.2.15.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EntityFramework.MappingAPI" publicKeyToken="7ee2e825d201459e" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-5.0.0.9" newVersion="5.0.0.9"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>


  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v12.0"/>
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>


    <chargify defaultAccount="TestSiteAccount">
      <accounts>
      <add name="TestSiteAccount" site="https://yoursubdomain.chargify.com" apiKey="AbCdEfGhIjKlMnOpQrSt" apiPassword="P" sharedKey="AbCdEfGhIjKlMnOpQrSt"/>
      </accounts>
    </chargify>

</configuration>

No comments:

Post a Comment