Streaming a Node.js Azure Website log

Following Scott Hanselman’s comprehensive blog post on logging in Windows Azure Websites, I tried it out with Node.js. Here’s how…

First, create your site, you can just do this in the portal or the command line as described in Scott’s post.

Create your node application, and write debug information to the console. Here’s a quick example:

var http = require('http');
http.createServer(function(req, res){
  console.log("Hello World");
  res.end("Hello World");

To enable logging, you need to set it up in the  iisnode.yml file. The easiest way to do this is to use a custom deploy script – which will give you access to the file. Run this command in the root of your app:


$> azure site deploymentscript NAME_OF_YOUR_SITE –node


Which will put a copy of the iisnode.yml in the same directory.

Edit this file and turn logging on by setting ‘loggingEnabled’ to ‘true’:


loggingEnabled: true
debuggingEnabled: false
devErrorsEnabled: false
node_env: production

Now deploy your site (using git or dropbox, or whatever!).

One deployed, you can stream your log using this command:

$> azure site log tail NAME_OF_YOUR_SITE

The log lines will appear in your console like this:

info: Executing command site log tail
2013-04-12T10:43:25 Welcome, you are now connected to log-streaming service.
Hello World
Hello World
Hello World
Hello World

If your site throws an uncaught exception, this will also show up.