Azure function apps logs not showing

33,222

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

enter image description here

Solution 5

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.

Share:
33,222
Kikanye
Author by

Kikanye

Updated on July 09, 2022

Comments

  • Kikanye
    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
    th3morg almost 6 years
    I 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
    gorillapower almost 6 years
    I 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
    Mariusz over 5 years
    Closing completely browser tab and reopening it helped me out. Maybe some issues with SignalR posting to the browser?
  • John VanZwieten
    John VanZwieten about 5 years
    I 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
    James Shapiro about 4 years
    FYI, 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
    boj over 3 years
    This way works...sometimes. But not always. Checking log files in the folder directly is reilable.
  • DerpDerp
    DerpDerp about 3 years
    This does not apply anymore. Also if you are running from a ziip file, you cannot edit hosts.json
  • Daniel Rudy
    Daniel Rudy over 2 years
    But how to you get to resources-event-functions? Please add that to your answer.
  • LoyalPotato
    LoyalPotato over 2 years
    @DanielRudy there you go :)
  • Krishna Santosh Nidri
    Krishna Santosh Nidri over 2 years
    There is only current day log file in this directory. Any idea where previous logs were moved (different directory)?
  • Heinrich Ulbricht
    Heinrich Ulbricht over 2 years
    For my .NET 6 function (runtime v4 dotnet-isolated) I cannot access any logs via Kudu. There is no debug console :/
  • Heinrich Ulbricht
    Heinrich Ulbricht over 2 years
    I 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
    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
    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
    Heinrich Ulbricht over 2 years
    Ok 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
    Creative almost 2 years
    Some people don't have Application Insights enabled as it comes with an extra cost.