Azure Diagnostics generate exception in SystemEventsListener::LoadXmlString when reading event log which includes exception as event data

 When you write Windows Azure application, you may wish you include you own error or notifications in the event log. Or you would like to save exceptions in the event log which ultimately collected by Windows Azure Diagnostics in the Azure VM and sent to Windows Azure Storage.

 

When you create an event log with Exception toString(), the event can’t be consumed by Azure Diagnostics instead you might see an exception in Azure Diagnostics module.

The exception shows a failure in SystemEventsListener::LoadXmlString while loading the event string.

 

If you dig deeper you will find that this exception is actually related with “xmlns” attribute present in your exception string as below:

 

<?xml version="1.0" encoding="utf-8" standalone="yes"?>

<error xmlns="https://schemas.microsoft.com/ado/2007/08/dataservices/metadata">

  <code>EntityAlreadyExists</code>

  <message xml:lang="en-US">The specified entity already exists.

       RequestId:46ce3b6e-d321-3b62-1e45-de45245fac17

       Time:2011-11-21T02:23:50.5356456Z</message>

</error>

 

This exception is caused by a known issue in Azure diagnostics component by the string “xmlns” being included in the content of an event log. 

 

To solve this problem you have two options:

  1. You can remove xmlns from the error data
  2. You also can replace double quote “ with single quote in the xmlns string