This appears to sporadically work, but most of the time it does not.
NOTE: If you take a look at the code, it is very, very simple. It writes "Boogie" to the context.log and then returns a 200 response:
'use strict';
module.exports = function(context){
context.log("Boogie");
context.res = {
status: 200,
headers: {
"Content-Type" : "application/json"
},
body : { "status" : "alive"}
}
context.done();
}
NOTE: You will receive a message:
{ "status" : "alive"}
NOTE: If you want to, turn on the web server logs, error tracing, etc for good measure.
Navigate to the URL another 3-4 times.
Within the SCM console go to:
D:\home\logfiles\Application\
Browse to your hearts content and try to find "Boogie" anywhere in any of the logs.
context.log writes to the logs.
It would also be nice if the documentation clearly indicated what needed to be turned on for this to work, if it did work at all.
Nothing gets logged at all. Every 100-200 times it seems like logging will miraculously turn on for a little bit and it will log, and then it will go back to no mans land.
None available.
Okay, this has been open two days without anyone commenting on this basic functionality not working.
I've walked through these steps myself several time, cleanly, on new apps and it always reproduces.
I would imagine that one of the following below must be the case:
As a result I fight the lack of response extremely puzzling. context.log is pretty basic functionality. I've got to think there are test cases for this for every build.
File logs are only for driving the portal debugging scenario when you're in the portal. If the portal has not connected in 15 minutes, the logs will disable themselves. This is for performance reasons. You can force file logs to stay on, but for high throughput scenarios that can of course have perf impact. I suspect that this accounts for the behavior you're seeing.
For steady state production monitoring, see the doc page here: https://docs.microsoft.com/en-us/azure/azure-functions/functions-monitoring. I agree that the documentation can be improved - also I don't think we mention the fact that file logging is time based anywhere. @christopheranderson @lindydonna do you know if we have this documented somewhere? If not it would be good to.
Thanks @mathewc, I've filed https://github.com/Azure/Azure-Functions/issues/187 to track the doc improvement.
@mathewc My reproduction steps specifically include turning on logging, and immediately hitting the app. This should log for at least 15 minutes as you're stating; but it does not do so.
I've also gone to the "Log Streaming" from the portal with the logs on. I do not get the output of context.log.
Unless I'm misunderstanding what you're saying, something is broken at least in my tenant.
Reopening until we get to the bottom of this. To clarify, you have the functions portal open when you're expecting logs? That's what I meant - generally we only write log files if you have the functions portal open on that particular function - i.e. you can see the function output in the portal window.
@mathewc I misunderstood what you said.
You are correct, if I go to:
App Services -> My Function to get the Function Dashboard, I then goto Function Name -> Monitor
It does successfully kick off logs that I can read on the file-system. The actual panel doesn't work for me and display anything in my real app since I had to implement CORS manually due to needing to allow cookies to be sent, but I can read the logs via SCM. Thank-you, I can work with this.
This is however, extremely misleading, since there is a setting for turning on App Logging explicitly under:
Function App -> Settings -> (Monitoring) Diagnostic Logs
If that doesn't do anything on a function app, it should at a minimum be disabled with something that points you where you can turn on logging for the function App.
Likewise, turning on log streaming in Visual Studio should be disabled for a function app and point you in the right direction for enabling what we're actually looking for.
Even better yet, if both options ALSO triggered the function app logging, that would make everything much more intuitive and make a lot more sense.
@Thanks for the feedback. I've opened https://github.com/Azure/Azure-Functions/issues/205 to track the issues you pointed out. I agree it is confusing. Closing the issue on this repo, since things are working as intended here.
This does not seem to be solved. I cannot, for the life of me, see anything sent to stdout either sing context.log or console.log. It is such a pity. I am on Consumption Plan and I am sure I saw it working in the Standard Plan. I don't know/don't want to know what is the difference there just reporting the info.
I think this issue should be reopened.
I am having the same issue :(
Me too.. it's impossible to debug.
Where are the stdout and stderr rerouted to in a nodejs function app? And console tab is giving the errors as the following
```bash
fa-...appname...:~$ cd
cd: -c: line 0: unexpected EOF while looking for matching `''
cd: -c: line 1: syntax error: unexpected end of file
fa-...appname...:~$ 'cd'
cd: -c: line 0: unexpected EOF while looking for matching `''
cd: -c: line 1: syntax error: unexpected end of file
````
So I don't know what this is supposed to be used for either
Most helpful comment
This does not seem to be solved. I cannot, for the life of me, see anything sent to stdout either sing
context.logorconsole.log. It is such a pity. I am on Consumption Plan and I am sure I saw it working in the Standard Plan. I don't know/don't want to know what is the difference there just reporting the info.I think this issue should be reopened.