39
votes

I'm relatively new to Azure and I just went through the tutorial on how to create a new Azure function, which is triggered when a new blob is created, and had this as the default code in it.

public static void Run(Stream myBlob, string name, TraceWriter log)
{
    log.Info($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
}

From what I can see on the tutorial, I should be able to see some information in the "logs" area below the code, but nothing shows up, I've been checking for a solution for a while now but can't seem to find anything useful.

Any help would be greatly appreciated.

7

7 Answers

50
votes

The log window is a bit fragile and doesn't always show the logs. However, logs are also written to the log files.

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.

7
votes

Azure Portal was updated last week and they moved logs from Monitor to the home of the actual Azure Function. However, to see them you need to click Test. I raised an issue with Microsoft support and they spent several days twiddling their thumbs before I came across the answer myself. I hope this saves others a bit of time

enter image description here

6
votes

Log messages should show under the function code, if you're watching that window at the time of the function's execution: Log window under function code

To view log messages made while you weren't looking, you'll need Application Insights configured. If that's configured, that should show under the Monitor tab: Monitor Tab with past log entries.

5
votes

Following the advice here worked for me. Configuring Log Level for Azure Functions

If you want to see your logs show up immediately in the Portal console after you press "Run", then go to your "Function app settings" and add the following to your host.json file:

"logging": {
    "fileLoggingMode": "always",
    "logLevel": {
        "default": "Information",
        "Host.Results": "Error",
        "Function": "Trace",
        "Host.Aggregator": "Trace"
    }
}

Note that this only worked for Javascript functions. For locally developed functions in other languages, the console can be a bit skittish.

4
votes

Microsoft keep changing the interface so many of these answers no longer are correct.

The best way I have found to view the logs is to go into Application Insights for the function itself and then search for some text that might be in the log in Transaction search.

0
votes

Indeed, the Logs section of the Function App in the Azure portal seems fragile. I had it open a few ours unused and then it did not log anything anymore. Closing the Function App and reopening it solved the problem.

0
votes

I would entirely avoid waiting for the logs to appear in the function app. Go over to Monitor on the left and go through it that way. Even then though there can be a solid 5 minute delay on them coming through. How on earth can aws be the only provider in this space that's able to give you logs immediately? GCP is bad for it as well.. (not sure about alicloud)