Azure function apps logs not showing
Solution 1
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.
Solution 2
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.
Solution 3
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.
Solution 4
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
Solution 5
Log messages should show under the function code, if you're watching that window at the time of the function's execution:
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:
Kikanye
Updated on July 09, 2022Comments
-
Kikanye almost 2 years
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.
-
th3morg almost 6 yearsI have tons of logs that are missing. It doesn't seem to write them to file storage within a reasonable time frame and every log file past yesterday is missing. Do I have a botched setting somewhere?
-
gorillapower almost 6 yearsI have a similar issue, whereby my function logs do not show (in Kudu or live stream), unless i go into the portal and click run, then subsequent logs show. Is this in line with your experience? Did anything come of your discussions with support?
-
Mariusz over 5 yearsClosing completely browser tab and reopening it helped me out. Maybe some issues with SignalR posting to the browser?
-
John VanZwieten about 5 yearsI found that functions need not be run this way to show in the Logs. For example, I was running a time-triggered funciton, and as long as I'm looking at the Log console at the time of execution I get to see the logged message, without clicking "Run."
-
James Shapiro about 4 yearsFYI, you can generally find real-time logs in Application Insights if you enable it (you may also need to add the "logging" section to the host.json per my response above). I agree that it's more of a hassle compared to viewing CloudWatch logs, but Azure does actually do a decent job here.
-
boj over 3 yearsThis way works...sometimes. But not always. Checking log files in the folder directly is reilable.
-
DerpDerp about 3 yearsThis does not apply anymore. Also if you are running from a ziip file, you cannot edit hosts.json
-
Daniel Rudy over 2 yearsBut how to you get to resources-event-functions? Please add that to your answer.
-
LoyalPotato over 2 years@DanielRudy there you go :)
-
Krishna Santosh Nidri over 2 yearsThere is only current day log file in this directory. Any idea where previous logs were moved (different directory)?
-
Heinrich Ulbricht over 2 yearsFor my .NET 6 function (runtime v4 dotnet-isolated) I cannot access any logs via Kudu. There is no debug console :/
-
Heinrich Ulbricht over 2 yearsI set all the darn properties[0] to
Trace
, nothing below "Information" is ever visible in the streaming logs. At least for my .NET 6 isolated function app. [0]: docs.microsoft.com/en-us/azure/azure-functions/… -
James Shapiro over 2 years@HeinrichUlbricht Yes, sorry, I can only speak to Javascript. I have had less luck with other languages like Python.
-
Heinrich Ulbricht over 2 years@JamesShapiro Thanks for the feedback. Yeah, not your fault :D But after hours of tinkering I'm a bit frustrated. At least I now know why a colleague did log everything with "Information" level...
-
Heinrich Ulbricht over 2 yearsOk I was using a shared app service plan and Kudu (log) file access is not supported there. Using a dedicated one lets me access the files.
-
Creative almost 2 yearsSome people don't have Application Insights enabled as it comes with an extra cost.