Adding Gibraltar to your ASP.NET website without recompiling

Welcome to day 24 of our Advent calendar. Yes folks, only one more sleep until Christmas.

Today we’re going to look at a great way to start using Gibraltar for logging even if you’ve got a deployed application. After all, not all web sites are in development and sometimes you want to add logging without making any code changes. So in this post we’re going to look at how you can add Gibraltar logging with a few simple changes to configuration, and the copying of the Gibraltar libraries to your web site.

The first thing you need to do is copy the Gibraltar libraries into your web site’s bin folder. The two libraries you need are:

  • Gibraltar.Agent.dll
  • Gibraltar.Agent.Web.dll

These are both in the SDK folder in your Gibraltar installation.

Next you must modify the web.config file to add reference to these libraries, in the modules and health monitoring sections. You web.config should end up looking something like this:

<configuration>
  <system.web>
    <httpModules>
      <add name="RequestTrackingModule" type="Gibraltar.Agent.Web.RequestTrackingModule, Gibraltar.Agent.Web"/>
    </httpModules>
    <healthMonitoring enabled="true" heartbeatInterval="0">
      <profiles>
        <add name="GibraltarProfile" minInstances="1" maxLimit="Infinite"
             minInterval="00:00:00"/>
      </profiles>
      <providers>
        <add name="Gibraltar"
             type="Gibraltar.Agent.Web.GibraltarEventProvider, Gibraltar.Agent.Web"/>
      </providers>
      <rules>
        <add name="Gibraltar Event Provider" eventName="All Events"
             provider="Gibraltar" profile="GibraltarProfile"/>
      </rules>
    </healthMonitoring>
  </system.web>
  <system.webServer>
    <modules>
      <add name="RequestTrackingModule"
           type="Gibraltar.Agent.Web.RequestTrackingModule, Gibraltar.Agent.Web"/>
    </modules>
  </system.webServer>
</configuration>

That’s it. Just save the config file, access your website, and Gibraltar will start logging the default events for you. Of course, you won’t get custom errors, but you will get notification of failures, which is the most important part of logging.

Note: Changing your web.config file will restart your application, losing all state. It’s best to do this as part of scheduled maintenance so your users don’t lose anything.

To read more on the configuration options, head to our documentation.

Well, that’s the end of our Christmas Advent calendar. Remember to tell us what feature is on your Gibraltar Software Christmas List? Share your ideas with us on Facebook and you’ll have a chance to win a fantastic prize!

Have a great Christmas everyone. I hope you’ve been good this year and Santa brings you what you wished for.

Rock solid centralized logging

Unlimited applications, unlimited errors, scalable from solo startup to enterprise.