John
John

Reputation: 10969

EventLog with Azure

I would like to be able to log events with Azure.

Currently, I am using EventLog and .WriteEntry to write it to a log on my local machine. However, I get a Request Error when I upload this to Azure.

I have seen guides that talk about using RoleManager in Microsoft.ServiceHosting.ServiceRuntime, but Microsoft.ServiceHosting.ServiceRuntime is not an available Reference to add (it says "Filtered to: .NET Framework 4, and Microsoft.ServiceHosting.ServiceRuntime is not in the list).

Is there a way to get logging working with .NET Framework 4 references?

Upvotes: 1

Views: 2466

Answers (3)

BrentDaCodeMonkey
BrentDaCodeMonkey

Reputation: 5513

ok, first off I always recommend to people to try and abstract away things like writing directly to the event log. Its a system dependency that is better expressed by using a loosely coupled provider. This way a particular piece of code you've created can be used either on premise or in Windows Azure by just changing the provider.

Secondly, there are security constraints around creating your own event sources. So I'm fairly certain that if this is what you are attempting to do, the operation will throw an exception.

And finally, the role manager issue isn't a bug. That class was deprecated when Windows Azure went commercial over a year ago. I wrote a short post that talked about it: http://brentdacodemonkey.wordpress.com/2010/03/05/azure-service-configuration-updated-or-%e2%80%9cwhere-did-rolemanager-go%e2%80%9d/

In your situation, I'd look into creating a simple adapter that writes directly to Azure Table Storage. Then you can let whatever event monitoring process you need periodically check that table. Alternatively, use Azure Storage Queues so you don't have to continually scan the table for new items. :) Just peek at the queue and pull and item when its found there.

Upvotes: 1

Adrian
Adrian

Reputation: 251

Don’t use Windows Event Logs in Azure. There’s no point. Develop your own logging solution. You may want to read Windows Event Log errors and warnings in order to forward to your logs. This could save some time with remote desktop troubleshooting.

Also don’t use Azure’s built in diagnostics. Most I have worked with have found this inadequate and burdensome to set up and configure. Also, there is a 1 minute delay before the logs are written due to batching on the machine.

Roll your own logging. What I have found the easiest to due as long as you don’t have to worry about storage account scale issues, is to write to a table. You will want to roll the log on a daily/hourly basis on table name and/or partition key depending upon how much logs you write (we write a LOT). You will probably also want to have your logs asynchronous with a producer/consumer pattern so you don’t slow down your processes. Critical logs (errors/warnings) you should write synchronously, or use another channel to report (we do not use logs to report errors but treat error reporting as a first class citizen).

If you start hitting scale issues of tables, you can do some in-process batching and append to a page blob. This is a bit more work, but you will be able to scale much better when you are logging a LOT.

Upvotes: 0

Related Questions