Ervis Trupja

Ervis Trupja

  • 1.8k
  • 141
  • 15.2k

Change value of a Specific Property in app.config using C#

Nov 12 2016 1:04 PM
I want to change the value of <level key="LoggingLevel" value="Test" /> from my app.config file using C#.
<?xml version="1.0" encoding="utf-8" ?>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
<appender name="FileAppender" type="log4net.Appender.FileAppender">
<file value="C:\dev\log-file.txt" />
<appendToFile value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="Level - %level%newline" />
<level key="LoggingLevel" value="Test" />
<appender-ref ref="FileAppender" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
I want to change the value from Test to Debug using C#. How can I do it?
Thanks in advance. :) 

Brought to you by:

Answers (2)