-
Notifications
You must be signed in to change notification settings - Fork 263
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
Durable Function with ILogger #1144
Comments
@eddynaka I don't think it is recommended to have the Logger on the class level. It is specific to each function execution. Also, I don't think you need DI for that as the framework will provide this dependency for you. Each function execution will receive a new logger instance automatically. But if you really need the log on class level, my guess is your DI will have to setup it for you. You may use the same env vars as the framework to get your logs to the same App Insights instance (not sure which keys they use, but you may look at the configuration screen on Azure platform). |
hi @cgillum , i was using ILogger because i'm using DI everywhere. So, i thought that removing that and adding the DI would work fine. When we add a new Azure Durable Function to a project, it creates this: [FunctionName("Function1")]
public static async Task<List<string>> RunOrchestrator(
[OrchestrationTrigger] DurableOrchestrationContext context)
{
var outputs = new List<string>();
// Replace "hello" with the name of your Durable Activity Function.
outputs.Add(await context.CallActivityAsync<string>("Function1_Hello", "Tokyo"));
// returns ["Hello Tokyo!", "Hello Seattle!", "Hello London!"]
return outputs;
} Can I add the ILogger here as well? |
@eddynaka Yeah, you can use |
I see...thanks for the response! |
Description
I created an Azure Durable Function with Application Insights (just enabled it in the portal).
Created the code above to inject ILogger:
With that, when debugging, it shows in the Console windows. But, when I publish to Azure, it doesn't log it in Application Insights.
Expected behavior
When using ILogger from DI, it should log in Application Insights
Actual behavior
Today, it's only logging in this scenario:
App Details
Screenshots
If deployed to Azure
The text was updated successfully, but these errors were encountered: