-
Notifications
You must be signed in to change notification settings - Fork 199
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
ILogger not logging to console after moving to Azure Functions OOB DI #1256
Comments
I believe you are hitting this issue where the functions run time aggressively filters logs. Could you try adding something like this in your {
"version": "2.0",
"logging": {
"logLevel": {
"<namespace>.MyService": "Information"
}
}
} To enable them for all classes in your nuget, you could do {
"version": "2.0",
"logging": {
"logLevel": {
"<namespace>": "Information"
}
}
} |
Thank you for jumping in @PramodValavala-MSFT - yes this is likely what it is. @brettsam we had a separate item tracking this before I believe? Is that still open? |
I will try and reply back. Kindly keep the thread open for some time |
Had the same issue and it indeed fixed it for me! |
I still didn't have time to check this as I was locked up in other stuff. If needed, kindly close the ticket. I will check back later and reach out if I face further trouble. Thanks for the support Microsoft. |
Its working fine. Thanks one more. You can close the ticket if required. |
As per Azure/Azure-Functions#1256 (comment) This still doesn't fix it
I'm having this issue, and the above-mentioned hosts.json fix doesn't resolve it for me. I've created a repro-case here: https://github.com/dracan/AzureFunctionsLoggingIssue Also, posted on StackOverflow yesterday before I found this current GitHub issue: |
This is another subtlety about how that console/debug log works in the portal. It only displays log messages if it knows they come from this function -- which means they match the category I've got an issue tracking this with one potential workaround: Azure/azure-functions-host#4689 (comment) |
Hi Azure Functions Team,
I followed the steps in https://docs.microsoft.com/en-us/azure/azure-functions/functions-dotnet-dependency-injection and was able to successfully implement Azure Functions OOB DI instead of using "GetService" to instantiate classes.
But after moving to the OOB DI, ILogger is not logging any information to the console when debugging locally (Still yet to deploy and testing using App. Insights).
Here is the snippet of the code I am using.
Startup.cs (OOB DI used, This file resides in an Azure Function Project)
Azure Function (.NET Core 2.1 project. DI works fine. Able to see the logged messages)
MyService.cs (This resides in a separate .NET Core 2.1 project. Class Library project, which is referenced to the Azure Function Project)
But Logged messages not appearing in the console
In the Startup.cs file, you would have noticed that I have two lines of code commented, ie
If I uncomment them, then I am able to see the logs from MyService.cs, but I think it should be supported DIed ILogger ie the above two lines shouldn't be required, right?, Should I use LoggerFactory separately?
I also tried Injecting
ILogger<MyService>
and alsoILoggerFactory loggerFactory
along with_logger = loggerFactory.AddConsole().CreateLogger<MyService>();
in the constructor of MyService.cs, but didn't log anything. The DI was successful for the logger, but it didn't log anything screen.Note: Both the Azure function and the Services project have Microsoft.Extensions.Logging 2.2.0 installed.
The text was updated successfully, but these errors were encountered: