azure function code logs info in first azure function and doesn't logs in another azure function

Viewed 97

Project 1 : it has 2 functions, Azure function 1 (afn1) & azure function 2 (afn2).

Both afn1 and afn2 are deployed to azure function app (afnapp1)

  • logs are displayed for afn1 and afn2.

Both afn1 and afn2 are deployed to azure function app (afnapp2)

  • logs are displayed for afn2 but not for afn1.
2 Answers

We have tested in our environment ,based on our findings we are able to see the logs of both the functions under a particular function app are getting recorded in the logs under the monitoring section of function app.

  • Azure Functions integrates with Application Insights to better enable you to monitor your function apps. Application Insights collects telemetry data generated by your function app, including information your app writes to logs. If your function app doesn't have the instrumentation key set, you must first enable Application Insights integration

  • Alternatively You can access these logs from the Kudu console: https://[your-function-app].scm.azurewebsites.net/

  • From the menu, select Debug console > CMD On the list of files, go into Logfiles > Application > Functions > Function > [Name of your function]

There you will see a list of log files.

You have to implement the Ilog for logs

Code:

this._log.Log(LogLevel.Information, nameof(FileTask), " file is empty").

Test log in local function app:

Function app log for login user

You can see the same in Azure function app hosted environment with help of App Insights:

Function app for logs

Note: You have to enable Application Insights to log the logs.

If you want to see the live log stream you can check here:

live log stream

Related