Programmatically edit the config files  
Author Message
Madhavan thasuramachandran





PostPosted: ASMX Web Services and XML Serialization, Programmatically edit the config files Top

Hi

We are developing an web application which has web services as the business tier, C# classes for data access tier and web forms as the front end application tier.

We are using Enterprice library for data, log4net for logging the events and WSE3.0 for security.

We have to develop an application, which has the ability to change the configuration setting for the above tiers.

I come across some of the msdn for editing the web.config files using System.Web.Configuration.

http://www.hide-link.com/

I have to edit the log4net settings and other custom tags developed in the development environment.

For Ex in the web.config file i have to edit the "bold" parts

<configuration xmlns=" http://www.hide-link.com/ ">

<log4net>

<!-- FileAppender appends to a log and it is manually managed or size -->

<appender name="OMXLogFileAppender" type="log4net.Appender.FileAppender">

<!-- D:\Documents and Settings\All Users\Start Menu\Programs\Administrative Tools-->

<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">

<param name="File" value="D:\Ingenix\igloo\omx\OMXSourceCode\Log\OMXLog.txt"/>

<param name="AppendToFile" value="true"/>

<rollingStyle value="Size"/>

<maxSizeRollBackups value="1"/>

<maximumFileSize value="20KB"/>

<staticLogFileName value="true"/>

<lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>

<layout type="log4net.Layout.PatternLayout">

<conversionPattern value="%date&#x9;%location&#x9;%-5level&#x9;[%thread]&#x9;%logger&#x9;%message%newline"/>

</layout>

</appender>

</appender>

<appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">

<applicationName value="InterfaceService"/>

<layout type="log4net.Layout.PatternLayout">

<conversionPattern value="%date&#x9;%location&#x9;%-5level&#x9;[%thread]&#x9;%logger&#x9;%message%newline"/>

</layout>

</appender>

<!-- Setup the root category, add the appenders and set the default level -->

<root>

<level value="ALL"/>

<appender-ref ref="OMXLogFileAppender"/>

<appender-ref ref="RollingFileAppender"/>

<appender-ref ref="EventLogAppender"/>

</root>

</log4net>

</configuration>

How to read the log4net using System.Web.Configuration..

Let me know if there is any solution for read and write the custom tags using System.Web,Configuration.

Regs,

Bell



.NET Development23