Share via


How to enable logging between Node.js and Azure

I’ve been playing with Node.js on Azure for the past couple of weeks.  In case you didn’t know, Node is a fully supported development option on Azure.  There’s an official open source SDK, which as of version 0.5.2 supports Azure tables, blobs, storage queues, ServiceBus queues, and ServiceBus topics.  You can even deploy to Azure from the Cloud9 online IDE using a Mac.  If you're a Node developer and are looking for a cloud provider, you should take a look at Azure.

There’s a lot of documentation on the Node.js Developer Center for Azure, and the GitHub page for the SDK, but I don’t recall seeing how to enable logging as of the release date for version 0.5.2 of the SDK.  It’s quite simple:

 var azure = require('azure');

var tableService = azure.createTableService();
tableService.logger = new azure.Logger(azure.Logger.LogLevels.DEBUG);

var blobService = azure.createBlobService();
blobService.logger = new azure.Logger(azure.Logger.LogLevels.DEBUG);

var queueService = azure.createQueueService();
queueService.logger = new azure.Logger(azure.Logger.LogLevels.DEBUG);

All sorts of information will then show up in the console which you can use to get a better understanding of what’s happening behind the scenes.  Comment out the lines which set the logger property to disable logging.