Forums will be making significant UX changes to address key usability improvements surrounding search, discoverability and navigation.
To learn more about these changes please visit the announcement which can be found
I've enabled diagnostics (per
my answer here). Now when I try to add a custom message to the log by:
in Global.asax (after diagnostic init obviously!)
EventLog.WriteEntry("Demo Webrole", "This is a message from global.asax", EventLogEntryType.Information);
I get a security exception as
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level
in the configuration file.
Exception Details: System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. To create the source, you need permission to read all event logs to make sure that the new source name is
unique. Inaccessible logs: Security.
So now it seems the default Windows Azure configuration won't allow log creation and I don't want to fight the platform by hacking priviledges etc (.NET trust level is "Full" by the way).
Our requirement is simple: We need a simple cloud aware diagnostic infrastructure so we can focus on the business logic itself.
So my question is: What is the simplest, straightforward way to get log messages out from the application into some persistant place? Code or links to working tutorials would be great!
Edited bySid.SThursday, September 20, 2012 2:38 AM
I faced this situation when the application tried to create a new Event Source for my Event Log messages. For doing this, the application needs admin priveleges. To work around this issue, we created a startup task which
helped us create the Event Source. That way, when the actual logging happened, the said Event Source was already created and ready for use. This is what our startp task contained:
EventCreate /L Application /T Information /ID 100 /SO "MyEventSourceName" /D "Created my custom source for logging my events" >> "%TEMP%\MyLog.txt" 2>&1
Thanks Pooja, I've marked it as an answer although we didn't test it.
We ended up going the route of writing custom logs directly to a file as we were doing before. The only difference is that this time we're writing to the file inside an Azure "Local Resource" and we're using WAD to move the Local Resource folder into an
Azure Blob. I might look into writing straight to Azure tables since our log format is essentially a table format but only if it doesn't take more than 20 minutes or so. And since our logging and tracing is managed centrally (in code) it should be easy to
swap it with the official method when the WAD tools and infrastructure mature (and there is solid documentation on how to consume it).
Edited bySid.SThursday, September 20, 2012 7:39 PM