azure-functions-core-tools icon indicating copy to clipboard operation
azure-functions-core-tools copied to clipboard

Option to output log category to Azure Functions Core Tools Function Runtime console and logfile

Open ghost opened this issue 5 years ago • 9 comments

What problem would the feature you're requesting solve? Please describe.

I'm always frustrated when I can see my log output in the Azure Functions Core Tools Function Runtime console but I cannot see what class is emitting the log entries because the log category is not included in output. This would be very useful during development and also to more easily understand and refine log filters.

Describe the solution you'd like

Add an option to allow the Category of the log to be output to the Azure Functions Core Tools Function Runtime console.

e.g. [26/02/2020 13:27:21] [category here] Initializing function HTTP routes [26/02/2020 13:27:21] [category here] No HTTP routes mapped [26/02/2020 13:27:21] [category here] [26/02/2020 13:27:21] [category here] Host initialized (364ms) [26/02/2020 13:27:21] [category here] Host started (652ms) [26/02/2020 13:27:21] [category here] Job host started [26/02/2020 13:27:21] [category here] Debug file watch initialized. [26/02/2020 13:27:21] [category here] Foo [26/02/2020 13:27:21] [category here] Bar [26/02/2020 13:27:21] [category here] Elephant

Describe alternatives you've considered

Thought I might get this from looking in the logfile created at %temp%\LogFiles\Application\Functions but whilst that has loglevel it too does not have log category. Log category is available in application insights but there is no local equivalent of application insights and using the cloud application insights is not a sensible option for cost and latency reasons.

Additional context

Add any other context or screenshots about the feature request here.

ghost avatar Feb 26 '20 13:02 ghost

@acrov Thanks for the suggestion! You should be able to inject a custom logger so you can see the category for your logs, would that work? Or did you want the category for all logs?

gzuber avatar Mar 03 '20 23:03 gzuber

Many thanks for the reply.

I could indeed inject a logger, although, as you imply, that would not work for logger output from the function host itself - knowing the logger category of function host output allows one to tune log filters appropriately.

Perhaps more importantly, logger injection simply doesn't work if you are not using DI - e.g. static void functions (as in all the azure function examples in the documentation).

Also, there is high utility and convenience, especially for people just getting started with Azure Functions, in just being able to look at output rigth there on the Tools Function Runtime console and not have work out how to hook up their own custom logger (or even know they can do that).

ghost avatar Mar 04 '20 08:03 ghost

Instead of injecting a logger, if one could inject a log format template into the built in logger that would work nicely.

Perhaps this could be specified somehow in the Host section of the local.setting.json where there seem to be other settings that affect the local function host - https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=windows#local-settings-file

ghost avatar Mar 04 '20 09:03 ghost

@acrov this is good input, thank you! Especially since we seem to be outputting category when running from Visual Studio. Unfortunately I can't promise anything, but I'll go ahead and Triage this so we can look into what we might be able to do.

gzuber avatar Mar 04 '20 20:03 gzuber

Please could you elaborate on "we seem to be outputting category when running from Visual Studio". When I run a function app in Visual Studio it runs the Tools Function Runtime and outputs to that. Where do you see the category?

ghost avatar Mar 05 '20 08:03 ghost

I would also like to see the format customization. I need to see the log level as text (e.g. [E] or [I]) for post-processing of the console output via pipes. Currently the log level can only be deduced from the message color (hello colorblind).

M0ns1gn0r avatar Jan 20 '21 12:01 M0ns1gn0r

Another +1 from me on the need for some kind of configurable logging format template.

aggieben avatar Nov 16 '21 23:11 aggieben

I like this suggestion as well. Quite often the only way to see this is in App Insights. Moving to Core Tools repo.

anthonychu avatar Nov 21 '21 00:11 anthonychu

Bump!

PingvinB avatar Oct 11 '25 15:10 PingvinB