2010-12-09 2 views
0

Ich möchte eine neue Konfigurationsabschnittsdefinition in <configSections> in meiner web.config Datei mithilfe des IIS7 Management Console-Konfigurationseditors hinzufügen und ein Skript generieren und dieses Skript in der Installation ausführen, um die Produktion des Clients zu aktualisieren Server.So fügen Sie eine neue benutzerdefinierte Abschnittsdefinition und ihre Details hinzu

konnte ich die Teildefinition mit dem folgenden Code hinzuzufügen:

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(); 

Aber ich weiß nicht, wie die Konfiguration Detail hinzufügen (siehe unten).

Wie mache ich das?

Abschnitt Definition:

<section name="loggingConfiguration" 
    type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, 
    Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, 
    Culture=neutral, PublicKeyToken=null" /> 

Abschnitt Details:

<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="All" name="General"> 
     <listeners> 
      <add name="RollingFile TraceListener" /> 
     </listeners> 
     </add>X 
     <add switchValue="All" name="Inbound Outbound Trans"> 
     <listeners> 
      <add name="RollingFile TraceListener" /> 
     </listeners> 
     </add> 
    </categorySources> 
    <specialSources> 
     <allEvents switchValue="All" name="All Events" /> 
     <notProcessed switchValue="All" name="Unprocessed Category" /> 
     <errors switchValue="All" name="Logging Errors &amp; Warnings"> 
     <listeners> 
      <add name="RollingFile TraceListener" /> 
     </listeners> 
     </errors> 
    </specialSources> 
    </loggingConfiguration> 

Antwort

0

Nach einigen Tagen der Forschung hatte ich die folgenden Schritte zu tun, um die erforderlichen Skripte zu generieren.

  1. erstellen custom_schema.xml mit der Schema-Definition für Logging Application Block (siehe unten) .. es ein sehr langwieriger Prozess ist
  2. kopieren, die Datei C: \ Windows \ System32 \ inetsrv \ config \ schema
  3. eine Section-Definition in der web.config (Anwendung web.config) manuell hinzufügen
  4. öffnen IIS7 Console-> Klicken Sie auf das Configuration Editor (Security Gruppe)
  5. Wählen Sie den oben hinzugefügt Abschnitt (es in der Liste erscheinen sollen - loggingConfiguration)
  6. Es sollte Ihnen zeigen, die komplette Definition
  7. Bearbeiten Sie den gewünschten Wert (Komische ist, dass wir alle bearbeiten haben Werte, auch wenn Sie die Standard Werte haben, da sonst nur die geänderten Werte im Skript)
  8. Sie können auf der Link Skript generieren klicken, erhalten

unten Probe custom_schema.xml Siehe

--- Protokollierung Applikationsblock Schema Details (CUSTOM_schema.xml)

<configSchema> 
    <sectionSchema name="loggingConfiguration"> 
<attribute name="name" type="string" /> 
<attribute name="tracingEnabled" type="bool" defaultValue="true"/> 
<attribute name="defaultCategory" type="string" defaultValue="General"/> 
    <attribute name="type" type="string" defaultValue="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"/>    
<element name="listeners"> 
    <collection addElement="add" removeElement="remove" clearElement="clear"> 
      <attribute name="fileName" required="true" type="string" defaultValue="c:\temp\log.log" /> 
    <attribute name="header" required="true" type="string" defaultValue="-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" /> 
    <attribute name="footer" required="true" type="string" defaultValue="-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" /> 
    <attribute name="formatter" required="true" type="string" defaultValue="Text Formatter" /> 
    <attribute name="listenerDataType" required="true" type="string" defaultValue="LogicaCMG.EnterpriseLibraryExtensions.Logging.Configuration.RollingFileTraceListenerData, LogicaCMG.EnterpriseLibraryExtensions.Logging, Version=0.5.2.0, Culture=neutral, PublicKeyToken=null" /> 
    <attribute name="traceOutputOptions" required="true" type="string" defaultValue="None" /> 
    <attribute name="type" type="string" required="true" defaultValue="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" /> 
    <attribute name="name" type="string" required="true" defaultValue="RollingFile TraceListener" /> 
    <attribute name="ageThreshold" type="string" required="true" defaultValue="1" /> 
    <attribute name="ageUnit" type="string" required="true" defaultValue="Days" /> 
    <attribute name="sizeThreshold" type="string" required="true" defaultValue="2" /> 
    <attribute name="sizeUnit" type="string" required="true" defaultValue="Megabytes" /> 
    <attribute name="maximumNumberOfLogs" type="string" required="true" defaultValue="20" /> 
    <attribute name="timestampFormat" type="string" required="true" defaultValue="MM-dd-yyyy HH-mm-ss" /> 
     </collection>  
</element> 
<element name="formatters"> 
    <collection addElement="add" removeElement="remove" clearElement="clear"> 
      <attribute name="template" required="true" type="string" defaultValue="Timestamp:{timestamp(local:F)}&#xA;Message: {message}&#xA;Category: {category}&#xA;Priority: {priority}&#xA;Severity: {severity}" /> 
    <attribute name="type" type="string" required="true" defaultValue="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" /> 
    <attribute name="name" required="true" type="string" defaultValue="Text Formatter" /> 
     </collection>  
</element> 
<element name="categorySources"> 
    <collection addElement="add" removeElement="remove" clearElement="clear"> 
      <attribute name="switchValue" required="true" type="string" defaultValue="All" />  
    <attribute name="name" required="true" type="string" defaultValue="General"/>  
    <element name="listeners"> 
    <collection addElement="add" removeElement="remove" clearElement="clear">  
     <attribute name="name" required="true" type="string" defaultValue="RollingFile TraceListener"/>  
    </collection> 
    </element> 
     </collection>   
</element> 
<element name="specialSources"> 
    <element name="allEvents"> 
    <attribute name="switchValue" type="string" defaultValue="All"/> 
    <attribute name="name" type="string" defaultValue="All Events"/> 
    </element> 
    <element name="notProcessed"> 
    <attribute name="switchValue" type="string" defaultValue="All"/> 
    <attribute name="name" type="string" defaultValue="Unprocessed Category"/> 
    </element> 
    <element name="errors"> 
    <attribute name="switchValue" type="string" defaultValue="All"/> 
    <attribute name="name" type="string" defaultValue="Logging Errors &amp; Warnings"/> 
    <element name="listeners"> 
    <collection addElement="add" removeElement="remove" clearElement="clear">  
    <attribute name="name" type="string" defaultValue="RollingFile TraceListener"/>  
    </collection> 
    </element>   
    </element>  
</element> 
    </sectionSchema> 
</configSchema> 
Verwandte Themen