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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:21:40+00:00 2026-05-15T08:21:40+00:00

I have a framework that uses log4net for logging, I know that we can

  • 0

I have a framework that uses log4net for logging, I know that we can disable or enable the desired logging in log4net via the config file. I want to develop some settings class so that the admin or user can set the logging etc.. What is the class etc in log4net to get the config file and change the settings in the config file via code? (are there any or should I use .net System.Xml) Any code snippets?

<?xml version="1.0" encoding="utf-8" ?>
<log4net>

  <root>
    <level value="ALL" />
    <!--<appender-ref ref="LogFileAppender" />-->
    <!--<appender-ref ref="ConsoleAppender" />-->
    <appender-ref ref="DEBUG-RollingLogFileAppender" />
    <appender-ref ref="Error-RollingLogFileAppender" />
  </root>

  <appender name="LogFileAppender" type="log4net.Appender.FileAppender" >
    <param name="File" value="log-file.txt" />
    <param name="AppendToFile" value="true" />
    <layout type="log4net.Layout.PatternLayout">
      <param name="Header" value="[Header]\r\n"/>
      <param name="Footer" value="[Footer]\r\n"/>
      <param name="ConversionPattern" value="%d [%t] %-5p %c %ndc %P{auth} - %m%n" />
    </layout>
  </appender>

  <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender" >
    <layout type="log4net.Layout.PatternLayout">
      <param name="ConversionPattern" value="%d [%t] %-5p %c %ndc %P{auth} - %m%n" />
    </layout>
  </appender>

  <appender name="DEBUG-RollingLogFileAppender" type="log4net.Appender.RollingFileAppender,log4net">
    <param name="File" value="..\\logs\\debug" />
    <param name="AppendToFile" value="true" />
    <param name="StaticLogFileName" value="false" />
    <param name="RollingStyle" value="Composite" />
    <param name="DatePattern" value=".yyyyMMdd'.log'" />
    <param name="MaxSizeRollBackups" value="30" />
    <param name="MaximumFileSize" value="5MB" />
    <layout type="log4net.Layout.PatternLayout,log4net">
      <!--<param name="ConversionPattern" value="%d [%t] %-5p %c %ndc %P{auth} - %m%n" />-->
      <param name="ConversionPattern" value="%d [%t] %-5p - %m%n" />
    </layout>
    <filter type="log4net.Filter.LevelRangeFilter">
      <!--<levelMin value="INFO" />-->
      <levelMax value="INFO" />
    </filter>
  </appender>

  <appender name="Error-RollingLogFileAppender" type="log4net.Appender.RollingFileAppender,log4net">
    <param name="Threshold" value="WARN"/>
    <param name="File" value="..\\logs\\errors" />
    <param name="AppendToFile" value="true" />
    <param name="StaticLogFileName" value="false" />
    <param name="RollingStyle" value="Composite" />
    <param name="DatePattern" value=".yyyyMMdd'.log'" />
    <param name="MaxSizeRollBackups" value="30" />
    <param name="MaximumFileSize" value="5MB" />
    <layout type="log4net.Layout.PatternLayout,log4net">
        <header value="&#13;&#10;" />
        <footer value="&#13;&#10;======================================================================" />
      <param name="ConversionPattern" value="%d [%t] %-5p - %m%n" />
    </layout>
  </appender>

</log4net>
  • 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. Editorial Team
    Editorial Team
    2026-05-15T08:21:40+00:00Added an answer on May 15, 2026 at 8:21 am

    Your question isn’t exactly clear: are you trying to change the currently-running configuration programmatically, or change the config file programmatically?

    If it’s the latter, I don’t think you need anything from log4net itself – and I wouldn’t particularly expect it to provide an API to manipulate the file. Instead, I’d use LINQ to XML (assuming .NET 3.5 or higher) and manipulate it myself directly. It’s pretty simple, by the looks of it. Study the configuration file format, work out what changes you’d want to make to it, then write the appropriate code for it. You shouldn’t even need to reference log4net for this.

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

Sidebar

Related Questions

I currently have a project that uses Entity Framework 4.1 for logging to a
I have an application that uses the .NET framework 3.5. I am building this
I have a wcf service that uses the .net System.AddIns framework to load assemblies
I have an iPhone app that uses the json-framework . I moved some of
I have a web application that uses the Spring Framework (3.1) and persistence through
My Google foo is failing me. If I have some framework that can do
I have an application that uses Entity Framework to access the data, and throughout
We have a WCF service that uses Entity Framework to query a SQL database.
I have a project that uses Zend Framework and Zend_Translate . I had to
I have a WPF app that uses an Entity Framework Model. One of the

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.