I'm working on some Python Function Apps using Linux and the consumption plan. I'm trying to figure out where I can see error logs from my apps without a lot of success. In particular I want to see two things:
If my app code fails to compile I get 404 errors when I try to access the API endpoint. Where do I see the compile error?
If my app throws an exception I get 500 errors from the endpoint. Where do I see the exception message and traceback?
Neither of these appear in any of the logging or insights screens I've been able to find. I've resorted to wrapping all my code in try/except blocks and returning the errors in my response but that's not great. I must be missing something obvious here!
Thanks for the help.
There are many ways you can monitor your Azure Functions Trigger, Refer below:-
I deployed one HTTP trigger function on Azure Portal from my local machine and triggered it to get the logs like below:-
Method 1) Go to your Azure Function app > Select your trigger > Code + Test > Test the Function and the Log stream will log all your Trigger's failure and success with error code, Refer below:-
And then you can change the logging type to either Verbose, Information, Warning, Error. If the above logs did not appear after you trigger your HTTP request or any function Trigger API, Just change the Logging to another type.
Method 2) Visit Monitor Section > and check for all the Trigger request invocations, warnings, errors like below:-
You can click on run query in Application insights and query the logs:-
Logs:-
Method 3)
You can visit your function app and select Logs tab and query Logs like below:-
You can visit Log Stream and find the same console Logs for your Function, This option is feasible when you have multiple Triggers inside one function app, Where it gives a single point to check the Function Trigger logs quickly:-
You can click on Metrics and get insights on your function's failed requests and other parameter like below:-
Refer my SO thread answer to send custom logs in Azure Function with Application Insights.
You can also add specific logging parameters in your host.json as referred from this MS Document on configuring Azure Functions logging.
{ "logger": { "categoryFilter": { "defaultLevel": "Information", "categoryLevels": { "Host": "Error", "Function": "Error", "Host.Aggregator": "Information" } } } }
App service Logs are disabled in Azure Function app with Consumption based plan, If you want to check App Service Logs and Advance tool kudu which also has details of your Function deployment and other Logs, You need to create your function app as Premium plan. Refer below:-
Function app > Development Tools > Advance Tools > Kudu > Go
Enable App Service logs:-
Reference:-