How to conditionally enable actions in C# ASP.NET website
<p>Using a configuration file I want to enable myself to turn on and off things like (third party) logging and using a cache in a C# website. The solution should not be restricted to logging and caching in particular but more general, so I can use it for other things as well.</p>

<p>I have a configuration xml file in which I can assert that logging and caching should be turned on or off (it could also be in the Web.Config, that's not the point right now) which will result in for example a <code>bool logging</code> and a <code>bool caching</code> that are <code>true</code> or <code>false</code>.</p>

<p>The question is about this part:
<strong>What I can do is prepend every logging/caching related statement with <code>if (logging)</code> and <code>if (caching)</code>.
What is better way of programming this? Is there also a programming term for this kind of problem? Maybe attributes are also a way to go?</strong></p>
