使用配置文件配置监控

Web.config 是用于存储 Windows Server AppFabric 中托管的 Web 应用程序的监控配置信息的 XML 文件。应用程序的主 Web.config 文件驻留在 Web 应用程序的根目录中。ASP.NET 使用分层配置方案来分隔配置信息。此分隔允许从其他配置文件继承配置设置以最小化子目录上的实际 Web.config 条目。

当配置更改提交到主 Web.config 文件时,将自动回收应用程序域。在某些情况下,可能不需要执行此操作。要避免回收应用程序域,请将应用程序的主配置信息分隔为独立存在于应用程序的 Web.config 文件的其他文件。配置部分将移到主 Web.config 文件所在的同一目录下的分隔文件中。然后,使用 .NET Framework v4 属性 SectionInformation::ConfigSource (https://go.microsoft.com/fwlink/?LinkId=183510) 从主 Web.config 文件中对其进行引用。

将主 Web.config 文件中与监控相关的配置信息分隔为链接的配置文件的步骤如下所示。

将配置信息移到分隔配置文件

  1. diagnostics 部分移到名为 DiagnosticsConfigSource.config 的分隔配置文件。

    主应用程序的 Web.config 文件 分隔 DiagnosticsConfigSource.config 文件
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
    

    <system.serviceModel> <diagnostics configSource="DiagnosticsConfigSource.config" /> </system.serviceModel>

    </configuration>

    <?xml version="1.0" encoding="UTF-8"?>
    <diagnostics etwProviderId="e8a6636e-1213-497e-b5c5-5350627e719e">
    <endToEndTracing propagateActivity="false" messageFlowTracing="false" />
    </diagnostics>
  2. behaviors 部分移到名为 ServiceBehaviorsConfigSource.config 的分隔配置文件。

    主应用程序的 Web.config 文件 分隔 ServiceBehaviorsConfigSource.config 文件
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
    

    <system.serviceModel> <diagnostics configSource="DiagnosticsConfigSource.config" /> <behaviors configSource="ServiceBehaviorsConfigSource.config" /> </system.serviceModel>

    </configuration>

    <?xml version="1.0" encoding="UTF-8"?>
    <behaviors>
    <serviceBehaviors>
    <behavior name="">
    <etwTracking profileName="EndToEndMonitoring Tracking Profile" />
    </behavior>
    </serviceBehaviors>
    </behaviors>
  3. microsoft.applicationServer 部分移到名为 MonitoringEventCollector.config 的分隔配置文件。

    主应用程序的 Web.config 文件 分隔 MonitoringEventCollector.config 文件
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
    

    <microsoft.applicationServer> <monitoring configSource="MonitoringEventCollector.config" /> </microsoft.applicationServer>

    <system.serviceModel> <diagnostics configSource="DiagnosticsConfigSource.config" /> <behaviors configSource="ServiceBehaviorsConfigSource.config" /> </system.serviceModel>

    </configuration>

    <?xml version="1.0" encoding="UTF-8"?>
    <monitoring>
    <default enabled="true" connectionStringName="ApplicationServerMonitoringConnectionString" monitoringLevel="HealthMonitoring" />
    </monitoring>

备注

这些分隔文件的名称是任意的。唯一要求是实际配置文件的名称与使用主 Web.config 文件中的 configSource 属性定义的名称精确匹配。

备注

当 AppFabric 用户界面中应用程序的监控级别更改后,将自动修改这些文件。

  2011-12-05