New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logging settings not working for Serverless API Blueprint #399
Comments
I'm going to start working on reproducing this now. What is the exception/problem you are seeing? |
I was expecting "This is a DEBUG comment" to appears in debug logs (console app and CloudWatch). They are not appearing neither one. |
Hi @matheusmaximo, I'm not sure why Debug logs don't work, but it could be related to aws/aws-logging-dotnet#52. For you, at least you are already using the correct Amazon.Lambda.Logging.AspNetCore logging library if you are using the Serverless API Blueprint. I don't think the solutions you recommended are appropriate. If you try creating some logs with other log levels, which should work, you will see that adjusting the log levels in the appsettings.json will correctly filter out low log levels. I'll talk with @normj to find out more about the complications with Debug logs. |
Looks like we have a bug in the Amazon.Lambda.AspNetCoreServer that is not pulling the log levels into the ILoggingBuilder. I'll investigate why that is happening. You can change the minimum in code by editing the class that extends from using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;
namespace LambdaLoggingDebugTest
{
public class LambdaEntryPoint : Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction
{
protected override void Init(IWebHostBuilder builder)
{
builder
.UseStartup<Startup>()
.ConfigureLogging((hostingContext, logging) =>
{
logging.SetMinimumLevel(LogLevel.Trace);
});
}
}
} |
I found the problem in the library causing the logging settings to not be correctly read from appsettings.json 0d3cdb3 I'll get the fix out soon. |
I just released version 3.0.2 of Amazon.Lambda.AspNetCoreServer which fixes the bug with logging not being read from config. |
I confirm that this fixed the problem. Thank you all! |
Steps to reproduce:
Create a new Serverless application using ASP.NET Core Web API from Blueprint
Amend ValuesController to have the following code:
Run code
Using postman, hit the ValuesController Get.
I can see 2 possible solutions here:
a) Amend appsetings.json to Logging section instead of Lambda.Logging
b) Amend this file aws-lambda-dotnet/blob/master/Libraries/src/Amazon.Lambda.AspNetCoreServer/AbstractAspNetCoreFunction.cs Line 179 to not include the Section "Logging"
The text was updated successfully, but these errors were encountered: