加载中

ASP.NET 上的配置

在监控 ASP.NET 应用程序时,代理使用两个配置来源

  • Web.config <appSettings> 部分
  • 环境变量

Web.config 的优先级高于环境变量,这意味着代理会首先尝试在 Web.config 中通过键查找配置选项的值。如果不存在,代理会尝试在环境变量中查找。如果仍不存在,代理将回退到选项的默认值。

您可以在相应选项描述的 IConfiguration or Web.config key 列中找到每个配置选项的键。

以下是用于 ASP.NET 应用程序的示例 Web.config 配置文件。

<?xml version="1.0" encoding="utf-8"?>
<!-- ... -->
<configuration>
    <!-- ... -->
    <appSettings>
        <!-- ... -->
        <add key="ElasticApm:ServerUrl" value="https://my-apm-server:8200" />
        <add key="ElasticApm:SecretToken" value="apm-server-secret-token" />
        <!-- ... -->
    </appSettings>
    <!-- ... -->
</configuration>
		

此外,在 ASP.NET 上,您可以实现自己的配置读取器。为此,请实现来自 Elastic.Apm.Config 命名空间的 IConfigurationReader 接口。实现后,您可以使用 FullFrameworkConfigurationReaderType 设置。

此设置仅适用于 .NET Full Framework。

此设置可以将代理指向自定义的 IConfigurationReader 实现,代理将从您的 IConfigurationReader 实现中读取配置。

使用 AssemblyQualifiedName 格式的类型名称(例如:MyClass, MyNamespace)。

环境变量名称 Web.config 键
ELASTIC_APM_FULL_FRAMEWORK_CONFIGURATION_READER_TYPE ElasticApm:FullFrameworkConfigurationReaderType
默认值 类型
None String

如果同时在 web.config 文件和环境变量中设置了此项,则 web.config 文件具有优先权。

© . This website operates independently and is not affiliated with or endorsed by Elasticsearch B.V. All brand names, logos, and trademarks are the property of their respective owners.