How to add new custom section definition and its Details

Dataklinik

New Member
I want to add new configuration section definition in \[code\]<configSections>\[/code\] in my \[code\]web.config\[/code\] file using the IIS7 Management Console Configuration Editor and generate a script and execute this script in the installation to update the client's production servers.I was able to add the section definition using the following code:\[code\]ServerManager serverManager = new ServerManager(); Configuration config = serverManager.GetWebConfiguration("Default Web site/upngisintegration"); SectionGroup rootSectionGroup = config.RootSectionGroup;SectionDefinition logSectiondef = rootSectionGroup.Sections.Add("loggingConfiguration"); logSectiondef.Type = @"Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"; serverManager.CommitChanges();\[/code\]However, I don't know how to add the configuration detail (see below).How do I do this?Section Definition:\[code\]<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" />\[/code\]Section Details:\[code\]<loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="General"> <listeners> <add fileName="C:\temp\xxxxx.log" ..snipped for brevity.. /> <add timestampFormat="MM-dd-yyyy HH-mm-ss" ..snipped for brevity... /> </listeners> <formatters> <add template="...." ..snipped for brevity.../> </formatters> <categorySources> <add switchValue="http://stackoverflow.com/questions/4403481/All" name="General"> <listeners> <add name="RollingFile TraceListener" /> </listeners> </add>X <add switchValue="http://stackoverflow.com/questions/4403481/All" name="Inbound Outbound Trans"> <listeners> <add name="RollingFile TraceListener" /> </listeners> </add> </categorySources> <specialSources> <allEvents switchValue="http://stackoverflow.com/questions/4403481/All" name="All Events" /> <notProcessed switchValue="http://stackoverflow.com/questions/4403481/All" name="Unprocessed Category" /> <errors switchValue="http://stackoverflow.com/questions/4403481/All" name="Logging Errors & Warnings"> <listeners> <add name="RollingFile TraceListener" /> </listeners> </errors> </specialSources> </loggingConfiguration> \[/code\]
 
Back
Top