-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Expand Logging Services section #32004
Comments
@danhamlin Thanks for the feedback! I have assigned the issue to the content author to evaluate and update as appropriate. |
It would be really helpful if it showed how to wire it up to send to AI, like the default |
Same here. Need to inject the default ILogger into service classes. |
Services registered in DI can get a logger like so (notice the generic that differs from what function methods get injected):
I'm using this in my function apps. |
@danhamlin that doesn't show how to register it or how it gets injected. I think you left something out of your example. |
Appologies, I goofed with the markdown, but I fixed it now. There is logging registered out of the box. If you want to add additional logging providers you can use something like the following in your startup class: |
So it appears the generic interface is what I was missing. Does it need to match the class being injected into? (I am planning to use it within a MediatR pipeline component--effectively middleware--and I'm not sure what the generic argument should be.) |
It compiles and runs without exception, though I don't see any log output in the console window (running the azure function in the local test environment). |
+ @brettsam and @jeffhollan for awareness of this discussion. cc. @craigshoemaker |
Couple of comments:
Numbers 1 and 2 are just general .NET Logging... you can read up more here: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-2.2 |
Thanks, @brettsam. I should have read up more but was confused because of |
Thank you. That fixed it for me. |
Just to make matters clear for future readers - The injected ILogger or ILoggerFactory will get injected properly but NOT actually write to any Logging Providers - in my case I was expecting to see it write to Application Insights and the Console. Due to the bug Azure/azure-functions-host#4345 Workaround is to add this to your host.json file
|
Moving to #please-close this issue as it's not a doc-related issue. |
Please give some expanded guidance in the Logging Services section.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: