Reputation: 1189
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"
}
}
Upvotes: 16
Views: 13460
Reputation: 424
Today I had this very issue and providing a type for ILogger is what worked.
Using ILogger<T>
instead of ILogger
and having "logLevel": { "default": "Information" },
in my host.json file.
As an extra bonus, if you would like to have your log messages stand out you can prefix your message with ANSI escape code values to colorize your text and background in the console. For example, \u001b[33m
for yellow, and \u001b[44m
for blue.
Upvotes: 0
Reputation: 40549
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)
Upvotes: 18