Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4610002
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:04:10+00:00 2026-05-22T01:04:10+00:00

I’m attempting to configure ELMAH error logging in an ASP.NET 4 application using SQL

  • 0

I’m attempting to configure ELMAH error logging in an ASP.NET 4 application using SQL Server 2008 R2. Is there any way I can tell ELMAH to call our in-house decryption function on the connection string we provide it? Do I need to modify the ELMAH source and rebuild?

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

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

<connectionStrings>
  <add name="ELMAH" connectionString="EncryptedConnectionString" providerName="System.Data.SqlClient" />
</connectionStrings>

<system.webServer>
  <handlers>
    <add name="Elmah" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
  </handlers>
  <modules>
    <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
  </modules>
</system.webServer>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T01:04:10+00:00Added an answer on May 22, 2026 at 1:04 am

    You can’t just tell ELMAH to do something with your connection string. What you can do, however, is tell ELMAH to call you back when it needs an ErrorLog, giving you more control at run-time. You can then read the encrypted connection string, decrypt it with your in-house function and return an SqlErrorLog initialized with it.

    To do this, you need to provide a method that is compatible with
    the ServiceProviderQueryHandler delegate. Here’s the definition:

    public delegate IServiceProvider ServiceProviderQueryHandler(object context); 
    

    The implementation of the method must return an instance of an object that implements IServiceProvider. If you don’t feel like writing one yourself to start with, you can get one for free from the .NET Framework. See System.ComponentModel.Design.ServiceContainer. The service provider’s GetService must respond to requests for the ErrorLog type and you can then, for example, return a SqlErrorLog object that has been initialized with a connection string manipulated at runtime. Here’s a possible implementation:

    var parent = ServiceCenter.Current;
    ServiceCenter.Current = context => { 
        var container = new ServiceContainer(parent(context)); 
        var connectionSettings = ConfigurationManager.ConnectionStrings["FOOBAR"];
        var connectionString = Decrypt(connectionSettings.ConnectionString);
        var log = new SqlErrorLog(connectionString); 
        container.AddService(typeof(ErrorLog), log); 
        return container; 
      } ;
    

    This captures the current service point and installs your own instead. The lambda/delegate created pass on service requests to the captured service point when it cannot
    satisfy it directly, thus creating a chain. You tell ELMAH about your implementation by setting ServiceCenter.Current somewhere during the initialization of your application so that’s where the above code will need to sit.

    Bear in mind that this is a very simple implementation but it should be good enough to get you started and optimize later if needed.

    Prior to this addition in 1.2, the only way to do something similar required subclassing and other gymnastics and still yielded partial results. Now you just need to implement a method and hand it over to ELMAH and which simply responds to queries from ELMAH for objects based on their service type.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have thousands of HTML files to process using Groovy/Java and I need to
I am using Paperclip to handle profile photo uploads in my app. They upload
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.