Del via


XML Namespace Issue in Azure Diagnostics Event Log Entries

I recently had a customer migrating an application to Azure whose policy is to send well-formed XML with detailed error information to the event log whenever errors are detected in their applications. The customer was getting errors when including XML namespaces in their detailed event log entries.  For example, their event log entries were constructed as follows: 

<InformationEvent xmlns:xsd=”https://www.w3.org/2001/XMLSchema” xmlns:xsi=”https://www.w3.org/2001/XMLSchema-instance”>…Data…</InformationEvent>

This looks fairly innocuous, but the problem is with the double quotes. In the Azure diagnostics monitoring, while processing a new event log entry, Azure diagnostics looks for xmlns entries as part of the xpath processing.  When looking for these xmlns entries, Azure diagnostics does a string comparison of the entire event log entry looking for xmlns, followed by a ‘, followed by another ‘.  So if we modify the string above as follows by substituting single quotes for double quotes, it correctly finds and processes the string:

<InformationEvent xmlns:xsd='https://www.w3.org/2001/XMLSchema' xmlns:xsi='https://www.w3.org/2001/XMLSchema-instance'>…Data…</InformationEvent>

This has now been reported as a bug, but the good news is that you have an easy workaround.