Thursday 6 November 2008

Azure: Logging in and out of the fabric

This article really ties two articles together.  In this article I talked about discovering whether you are running normally or in the Fabric, and in this second article I talked about logging in Windows Azure

The following line of code is how you write to a log within the Fabric (in azure)

RoleManager.WriteToLog("Critical", "I am a critical error");


If however you try to run this line of code when you are not in the Fabric (e.g. normal asp.net web application), you will get an Object Reference exception.



Therefore having a common logging class which checks whether you are running in the Fabric or running normally would be a pretty useful thing.



And you can achieve that by combining this post and the other 2 posts.

1 comment:

Swati Jaiin said...

I also got the same error - Object reference not set to an instance of an object when trying to set Rolemanager.WriteToLog from the client. The point is when I try to do this from my web project, it goes well but, when I have a seperate client project calling the same service to write to log, I get this error.
I did what you suggested, checked whether role manager was running before write to log. So it will not raise and exception. But, how to correct it, how to make it write in the log.
How to make the client run in the fabric.