0
votes

How do you do "console.log()" in a NodeJS site deployed to Azure, and actually access the logs without just dumping to blob storage? We've tried several methods, but can't find a method that makes it easy to access the logs.

What we've tried:

Table Storage

We've turned on table storage through the portal, and that doesn't pick up anything. With .NET apps we can use TRACE statements and that works fine.

IISNode/Kudu

We've configured a iisnode.yml file with the following,

nodeProcessCommandLine: "D:\Program Files (x86)\nodejs\5.3.0\node.exe"
loggingEnabled: true
devErrorsEnabled: true

And added a rule to our web config file.

<rule name="LogFile" patternSyntax="ECMAScript" stopProcessing="true">  
   <match url="iisnode"/>  
</rule> 

This seems to dump data to some files in Kudu, accessable from:

https://sitename.scm.azurewebsites.net/DebugConsole

Files located at: Home\Application\LogFiles

BUT... how do you access the index.html file, without downloading it??? Even after pulling it.... its incredibly difficult to read through and not very helpful.

So, the Question:

How do you get Node logging configured in Azure, that provides the logs in an easy to read way?

2

2 Answers

2
votes

As I know, the information level logging will be writed into the files named matching the pattern *-stdout-*.txt at the Kudu path D:\home\LogFiles\Application\ by the function console.log on Azure NodeJS WebApp.

You can try to get the json list of the log files in that Kudu path \LogFiles\Application\ via access the url https://<your_webapp_name>.scm.azurewebsites.net/api/vfs/LogFiles/Application/, and filter the items matching the pattern *-stdout-*.txt and get them in programming.

The simple way to read the logs is accessing the url https://<your_webapp_name>.scm.azurewebsites.net/api/vfs/LogFiles/Application/index.html that is the url of index.html file in Kudu. Then you can click the log link to browse the log. enter image description here

Or you can try to install an extension called Azure Web Site Logs Browser via search the word logs at the tab Gallery on the tab page Site extensions of Kudu, then you can read the logs in the File System - Application Logs via the url https://<your_webapp_name>.scm.azurewebsites.net/websitelogs/.

enter image description here

1
votes

have you tried enabling diagnostic log for your nodejs app?

Enable diagnostics logging for web apps in Azure App Service

To view log without downloading it, have you tried log stream?

Diagnostic Log Stream