Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
ILogger Log method is missing constraints? #1630
today I was playing a bit with
I believe this problem is caused by the fact, that
I hope I'm not duplicating this issue, if this is intended, there's a gap in the documentation.
In logs I should see something similar to
The message is not logged
I can use
This was fixed with this PR, but hasn't yet rolled out to production: Azure/azure-webjobs-sdk#1174. Now, the logger will check and if you have a string that we can write out as a message, we will, regardless of what the state object is. If the state object is an
For your scenario, though, your best approach is to use the built-in
This is explained briefly here: https://github.com/Azure/azure-webjobs-sdk-script/wiki/ILogger#structured-logging.
@brettsam Does it mean that I'll be able to use
If passing a custom type is not a case(since it will be casted to
You'll be able to log with what you have, but it doesn't get you much. Your state will be ignored and we'll log the string. What did you want to happen when you pass in that type? All of the registered loggers need to know how to handle it.
As for the constraint: we don't own that interface; it's part of the
What I expected from this method was to actually use my formatter and take advantage of passed state(possibly combine it with an exception and transform a string if needed). Due to current shape it's a bit confusing. On the other hand I see the point, that
Anyway thanks for clarifying this!
Oh, of course! Let me rephrase -- yes, your formatter will be called with your state. We won't do anything special with that state, though -- we just pass it straight to your formatter. That will happen here: https://github.com/Azure/azure-webjobs-sdk/blob/dev/src/Microsoft.Azure.WebJobs.Logging.ApplicationInsights/ApplicationInsightsLogger.cs#L31
Using an extension like