I am looking to use the nuget package AWS.Logger.AspNetCore to implement ASP.NET Core Logging in an ASP.NET Core 2.0 Razor Pages application.
The examples on the project site are based upon ASP.NET Core 1.0.
So the examples show:
In the appsettings.json file:
"AWS.Logging": {
"Region": "us-east-1",
"LogGroup": "AspNetCore.WebSample",
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
and in 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());
...
Can someone please show the equivalent of this in ASP.NET Core 2.0? And how to then inject the logger into a Razor code behind (.cshtml.cs) page? (I'm using ASP.NET Core Razor Pages, not MVC)
I've looked at Microsoft's page on Logging in ASP.NET Core that shows how to add providers, but I can't figure out how to relate this to adding the AWS Logger within Startup.cs