我们已将日志记录配置存储在AWS参数存储中。我们使用Amazon.Extensions.Configuration.SystemsManager(nuget包)读取配置,并使用AWS.Logger.AspNetCore(nuget)通过.NET core写入云监视。
这是我们设置系统管理器的代码
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureAppConfiguration(config =>
{
config.AddSystemsManager(g =>
{
g.AwsOptions = new Amazon.Extensions.NETCore.Setup.AWSOptions();
g.AwsOptions.Region = RegionEndpoint.USEast1;
g.Path = $"/Dev/FileService";
});
})
.UseStartup<Startup>();
这是日志记录配置的代码
//This line retreives the json data
var t = Configuration["AWS.Logging"];
//This returns a null
AWSLoggerConfigSection awsLoggingConfig = Configuration.GetAWSLoggingConfigSection();
我在参数存储区和以下JSON中定义了一个参数键“ /Dev/FileService/AWS.Logging”
{
"Region": "us-east-1",
"LogStreamNameSuffix": "fileservice",
"LogGroup": "imagerservice",
"LogLevel": {
"Default": "Error",
"System": "Error",
"Microsoft": "Error"
}
}
问题是,如果执行以下操作,我可以检索此日志记录配置
var t = Configuration["AWS.Logging"];
但是此代码始终返回null
AWSLoggerConfigSection awsLoggingConfig = Configuration.GetAWSLoggingConfigSection();
有什么主意吗?