0

I'm setting up logging for Azure service. Currently, messages I get in wadlogstable look like this:

<Properties>
  <EventTickCount SqlType="bigint">635193311660155844</EventTickCount>
  <DeploymentId SqlType="nvarchar(max)">deployment21(67)    </DeploymentId>
  <Role SqlType="nvarchar(max)">HTMLConverterWebRole    </Role>
  <RoleInstance SqlType="nvarchar(max)">deployment21(67).HTMLConverterWrapper.Cloud.HTMLConverterWebRole_IN_0   </RoleInstance>
  <Level SqlType="int">2</Level>
  <EventId SqlType="int">0</EventId>
  <Pid SqlType="int">6900</Pid>
  <Tid SqlType="int">14840</Tid>
  <Message SqlType="nvarchar(max)">2013-11-06 12:39:25.8449|ERROR|My error message</Message>
</Properties>

I haven't been to production yet, but I suppose that it's pretty inconvenient to search in xml. What are the best practices for this? Can I customize the elements in it? I don't think I really need Pid, Tid, also I don't see a purpose of EventId.

Update: I'm actually using NLog right now, but I'm doing it as described here: http://awkwardcoder.blogspot.com/2012/03/getting-nlog-working-with-azure-is-as.html

So it posts logs to Trace target and as I understand traces are captured by DiagnosticMonitorTraceListener, ending in Windows Azure table. So I'm using NLog to format my "Message" element in the resulting xml, also "Level" and "EventId" are elements are dependent on which NLog method I call (Logger.Debug* or Logger.Error* etc.), but I don't have access to general format of this xml. Also, I would probably prefer custom logging table with dedicated fields for "Level", "Date" and so on, so I don't have to parse it in each log query.

ptkvsk
  • 2,096
  • 1
  • 25
  • 47

2 Answers2

1

Unfortunately you don't have control over the format of the data which gets logged automatically by Windows Azure Diagnostics. You could get fine grained control if you use custom logging. For custom logging you could use something like NLog. In that scenario, the data logged by your application is stored in files and get automatically transferred to blob storage using Windows Azure Diagnostics.

Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241
  • Thanks for your answer, please see the updated question. Could you please give more information (a link or smth) on how to implement custom logging in Azure? I'm wondering if it's possible to log in a custom table with custom schema. – ptkvsk Nov 06 '13 at 11:44
  • Do take a look at this blog post: http://blogs.msdn.com/b/windowsazure/archive/2013/06/28/telemetry-basics-and-troubleshooting.aspx. For our application, we basically customized their solution. In our case, we are only storing the errors through diagnostics. For everything else (like application tracing etc.), we write the stuff using NLog which gets transferred to blob storage and then read from there to push in table storage. – Gaurav Mantri Nov 06 '13 at 12:02