Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get logs while running Azure functions locally?

I'm developing / debugging my Function App locally on mac High Sierra by azure-functions-core-tools v2.2.70. My app is based on Node.js 8.11.1.

When my app is published on Azure, I can get the logs which are logged by context.log("sample message"), however, while running the app locally by func host start, I don't see any of my customs logs. That is, if I log something by context.log or console.log, I will not see it.

I even tried NODE_OPTIONS=--inspect func host start, but even that didn't help.

Can you please tell me how can I get my custom logs? Because without logging, debugging gets difficult.

FYI, in my host.json, I have following:

{
  "version": "2.0",
  "tracing": {
    "consoleLevel": "verbose"
  },
  "logging": {
    "fileLoggingMode": "always"
  }
}
like image 211
Mahdi Avatar asked Nov 28 '18 14:11

Mahdi


1 Answers

This worked for me:

{
    "version": "2.0",
    "logging": {
        "logLevel": {
            "default": "Debug"
        }
    }
}

It allowed me to see log output in the terminal when starting with func host start (CLI)

like image 93
goofballLogic Avatar answered Nov 03 '22 17:11

goofballLogic