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

  • SEARCH
  • Home
  • 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 35413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T14:13:55+00:00 2026-05-10T14:13:55+00:00

Using a configuration file I want to enable myself to turn on and off

  • 0

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.

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 bool logging and a bool caching that are true or false.

The question is about this part: What I can do is prepend every logging/caching related statement with if (logging) and if (caching). 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?

  • 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. 2026-05-10T14:13:56+00:00Added an answer on May 10, 2026 at 2:13 pm

    I’m curious what kind of logging/caching statements you have? If you have some class that is doing WriteLog or StoreCahce or whatever… why not just put the if(logging) in the WriteLog method. It seems like if you put all of your logging caching related methods into once class and that class knew whether logging/caching was on, then you could save your self a bunch of If statements at each instance.

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

Sidebar

Related Questions

I'm trying to persist user settings to a configuration file using ConfigurationManager. I want
Ok, so here's what I want to do. Create a configuration file using XAML
I'm using Python's ConfigParser to create a configuration file. I want to check if
I'm writing an INI-like configuration file and I want to know the best way
I'm trying to filter a Spring configuration file using Maven filtering. My POM is
How do you load a .user.ini PHP configuration file when using the built in
I'm using apache commons library and log4j. I have an xml configuration file and
For updating in my .properties file I am using Apache Commons Configuration's PropertiesConfiguration .
I am using Fluent NHibernate with an external 'hibernate.cfg.xml' file. Following is the configuration
I am using configuration injection for gradle and have something like this subprojects {

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.