question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NodeJS: context.log Not logging Anywhere

See original GitHub issue

This appears to sporadically work, but most of the time it does not.

Repro steps

  1. Configure a new Azure Functions app to continuously deploy from the following repository: https://github.com/securityvoid/azure-bug.git

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();
}
  1. Navigate to the URL for the function. e.g. http://azure-bug.azurewebsites.net/api/1.0/test

NOTE: You will receive a message: { "status" : "alive"}

  1. Turn on Application logging within the console: Settings -> Diagnostic Logs -> Application Logging (FileSystem)

NOTE: If you want to, turn on the web server logs, error tracing, etc for good measure.

  1. Navigate to the URL another 3-4 times.

  2. 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.

Expected behavior

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.

Actual behavior

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.

Known workarounds

None available.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
arichiardicommented, Jan 11, 2019

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.

0reactions
ilayncommented, Dec 18, 2019

Where are the stdout and stderr rerouted to in a nodejs function app? And console tab is giving the errors as the following


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

Read more comments on GitHub >

github_iconTop Results From Across the Web

context.log vs console.log in Azure function apps
log are captured at the Function App level. This means that outputs from console.log are not tied to a specific function invocation, and...
Read more >
node.js Azure function context log not logging synchronously
Any ideas on why this is happening and how to remedy this? Issue seems to be confined in azure context's log as console.log...
Read more >
Context-aware logging in Node.js
One of the most basic requirements of good application monitoring is to have robust logging to keep track of everything that's going on....
Read more >
Node.js Logging Tutorial
Node.js logging is an important part of supporting the complete application life cycle. From creation to debugging to planning new features, logs support...
Read more >
Node.js Logging Best Practices: Getting Started Guide
Discover the best practices for efficient Node.js logging. Guide with hands-on examples of how to check and analyze logs to improve ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found