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 147025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:42:30+00:00 2026-05-11T08:42:30+00:00

I have a project I am working on using log4net, and it works great,

  • 0

I have a project I am working on using log4net, and it works great, but I want to know if i can override the XML configuration for the root ‘level’ attribute for the logging when in debug and release.

Currently my root configuration looks like:

<root>   <level value='WARN'/>   <appender-ref ref='LogFileAppender'/>   <appender-ref ref='DebugAppender'/> </root> 

And in my web applications Global.asax class, I was thinking I could wrap something in a

protected override void Application_Start(object sender, EventArgs e) {   base.Application_Start(sender, e);   XmlConfigurator.Configure();    #if DEBUG   //Change logging level to DEBUG   #endif } 

To change the root logging level to debug when the solution is built in debug.

Is this possible, is my idea a best-practises type soltuion to what I want, and how would I do it (or how would you do it better)?

  • 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-11T08:42:30+00:00Added an answer on May 11, 2026 at 8:42 am

    I do the oposite, in debug mode I use the developer configurations which is better for filtering the relevant messages for me; and in release mode, I lock the level to WARN to prevent a user wants to hack my code (he could use tons of other ways, but this is a 5 seconds trick):

    public static void Initialize() {  #if DEBUG     ConfigureAndWatch(); #else     ConfigureAndLockChanges(); #endif  }  #if DEBUG  private static void ConfigureAndWatch() {     XmlConfigurator.ConfigureAndWatch(new FileInfo('log4net.config')); }  #else  private static void ConfigureAndLockChanges() {     // Disable using DEBUG mode in Release mode (to make harder to hack)     XmlConfigurator.Configure(new FileInfo('log4net.config'));     foreach (ILoggerRepository repository in LogManager.GetAllRepositories())     {         repository.Threshold = Level.Warn;     } }  #endif 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an audio project I'm working on using BASS from Un4seen. This library
I have started using Linq to SQL for a project im working on and
In the project I am working I have deployed a SOAP server using Deployment
I am using MySQL and PHP for a project I am working. I have
I have a working copy of my project, checked out using Subversion 1.5.1. When
I'm working on my 1st project using MS Unity IoC framework. If I have
I'm working on a new project and I'm using the repository pattern, I have
I have a project that I'm currently working on but it currently only supports
Backstory: I'm using log4net to handle all logging for a project I'm working on.
Recently I have been working on a project where, among other things, we want

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.