C# 如何将AWS ASP.NET Core日志添加到ASP.NET Core 2.0 Razor Pages应用程序?

C# 如何将AWS ASP.NET Core日志添加到ASP.NET Core 2.0 Razor Pages应用程序?,c#,amazon-web-services,asp.net-core,razor-pages,C#,Amazon Web Services,Asp.net Core,Razor Pages,我希望使用nuget包在ASP.NET Core 2.0 Razor Pages应用程序中实现 项目站点上的示例基于ASP.NET Core 1.0 因此,示例显示: 在appsettings.json文件中: "AWS.Logging": { "Region": "us-east-1", "LogGroup": "AspNetCore.WebSample", "LogLevel": { "Default": "Debug", "System": "Informati

我希望使用nuget包在ASP.NET Core 2.0 Razor Pages应用程序中实现

项目站点上的示例基于ASP.NET Core 1.0

因此,示例显示:

在appsettings.json文件中:

"AWS.Logging": {
  "Region": "us-east-1",
  "LogGroup": "AspNetCore.WebSample",
  "LogLevel": {
    "Default": "Debug",
    "System": "Information",
    "Microsoft": "Information"
  }
}
在Startup.cs中

public Startup(IHostingEnvironment env)
{
    // Read the appsetting.json file for the configuration details
    var builder = new ConfigurationBuilder()
        .SetBasePath(env.ContentRootPath)
        .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
        .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
        .AddEnvironmentVariables();
    Configuration = builder.Build();
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    // Create a logging provider based on the configuration information passed through the appsettings.json
    loggerFactory.AddAWSProvider(this.Configuration.GetAWSLoggingConfigSection());

    ...
有没有人能在ASP.NET Core 2.0中展示类似的功能? 然后如何将记录器注入Razor代码隐藏(.cshtml.cs)页面?(我使用的是ASP.NET核心剃须刀页面,而不是MVC)


我已经看过了微软展示如何添加提供者的软件,但我不知道如何将其与在Startup.cs中添加AWS记录器联系起来。该方法对于razor或多或少是相同的

public Startup(IHostingEnvironment env)
{
    // Read the appsetting.json file for the configuration details
    var builder = new ConfigurationBuilder()
        .SetBasePath(env.ContentRootPath)
        .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
        .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
        .AddEnvironmentVariables();
    Configuration = builder.Build();
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    // Create a logging provider based on the configuration information passed through the appsettings.json
    loggerFactory.AddAWSProvider(this.Configuration.GetAWSLoggingConfigSection());

    ...
public class PersonModel : PageModel {
   ILogger<PersonModel> Logger { get; set; }

    public PersonModel(ILogger<PersonModel> logger)
    {
        this.Logger = logger;
    }
}