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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:51:51+00:00 2026-05-11T14:51:51+00:00

I’m looking for tips on the best way to reconfigure the Log4Net logging level

  • 0

I’m looking for tips on the best way to reconfigure the Log4Net logging level dynamically in my ASP.NET apps. I generally use a simple configuration where the root logger defines the default logging level, e.g.

<log4net>     <root>     <level value='INFO' />     <appender-ref ref='...' />     <appender-ref ref='...' />     ... etc ...          </root>     ... etc 

and there may be several appenders, each with filters to define the logging levels they use.

  1. The first thing I’d like to be able to do would be to allow Administrators to connect to an admin page that enables them to (a) view the current level for the root logger and (b) dynamically change it. I don’t want to use ‘ConfigureAndWatch’ and write to the configuration file on disk because I don’t want these changes to persist when the application is recycled.

  2. Next I’d like to go further, and on an Admin page be able to display a TreeView with all current Loggers that exist in the application, and their current logging level. And allow the administrator to be able to change the logging level selectively at any level of the hierarchy.

The idea is to to create a generic admin page that I can put into all my apps that allows administrators to selectively enable DEBUG-level logging dynamically for troubleshooting purposes.

I find the Log4Net APIs a bit confusing, can anyone point to samples or show the best way to achieve this.

Update:

Both answers are equally good so I’ve accepted the first – thanks. To reprise, I can get all current loggers as follows:

foreach (log4net.ILog log in log4net.LogManager.GetCurrentLoggers()) {     log4net.Repository.Hierarchy.Logger logger =           (log4net.Repository.Hierarchy.Logger)log.Logger;     Debug.WriteLine(         String.Format('{0} Parent {1} Level {2} EffectiveLevel {3}<br>',         logger.Name,         logger.Parent.Name,         logger.Level == null ? '<null>' : logger.Level.Name,         logger.EffectiveLevel         )         ); } 
  • EffectiveLevel is the effective level – same as Level if the latter is not null, otherwise inherited from the parent.

  • At least one of the loggers returned above will have the root logger as parent, which enables me to get a reference to the root logger.

With the above it should be possible to reconstruct the logger hierarchy.

Update 2

Thanks again. I’ve implemented an ASP.NET server control that displays the logger hierarchy in a TreeView with checkboxes, and allows the user to dynamically change the logging level at any node in the hierarchy. Works great and I’ll be putting it on Admin page in all my ASP.NET Web and Web Service apps!

  • 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-11T14:51:52+00:00Added an answer on May 11, 2026 at 2:51 pm

    Are you looking for something like this (untested code):

    foreach (ILog logger in log4net.LogManager.GetCurrentLoggers()) {   ((log4net.Repository.Hierarchy.Logger)logger).Level =        log4net.Core.Level.Error; } 

    You could obviously pull out the logger name, etc. in the same manner.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I would like to count the length of a string with PHP. The string
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.