I've enabled diagnostics logging to Blob Storage for an Azure Website I am trying on. I've also set Nlog to write to Trace
, so that they are then in turn written to the Azure blob. Nlog layout is set to CSV. This works, and the generated logs are outputted to the blob storage. If this was logging to a traditional file, that file would be a CSV file which I can open in excel, to analyse better the log files.
Nlog configuration file copied below:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!--
See http://nlog-project.org/wiki/Configuration_file
for information on customizing logging rules and outputs.
-->
<targets>
<!-- add your targets here -->
<!--
<target xsi:type="File" name="f" fileName="${basedir}/logs/${shortdate}.log"
layout="${longdate} ${uppercase:${level}} ${message}" />
-->
<target xsi:type="Trace" name="trace" >
<layout xsi:type="CsvLayout" >
<column name="shortdate" layout="${shortdate}" />
<column name="time" layout="${time}" />
<column name="logger" layout="${logger}"/>
<column name="level" layout="${level}"/>
<column name="machinename" layout="${machinename}"/>
<column name="processid" layout="${processid}"/>
<column name="threadid" layout="${threadid}"/>
<column name="threadname" layout="${threadname}"/>
<column name="message" layout="${message}" />
<column name="exception" layout="${exception:format=tostring}" />
</layout>
</target>
</targets>
<rules>
<!-- add your logging rules here -->
<logger name="*" minlevel="Trace" writeTo="trace" />
<!--
<logger name="*" minlevel="Trace" writeTo="f" />
-->
</rules>
</nlog>
Windows Azure diagnostics saves the diagnostics info as a CSV file in the blob storage. The CSV file has the below columns.
date,level,applicationName,instanceId,eventTickCount,eventId,pid,tid,message,activityId
However, the entire NLog message is written in the Message
column. This is probably because it saves the Diagnostics.Trace
message there, in which NLog is saving it'slogs. For example:
2014-05-07T12:18:49,Information,KarlCassarTestAzure1,10cd67,635350619297036217,0,2984,1,"2014-05-07,12:18:49.6254,TestAzureWebApplication1.MvcApplication,Info,RD0003FF410F59,2984,1,,Application_Start,",
The NLog message is the below:
"2014-05-07,12:18:49.6254,TestAzureWebApplication1.MvcApplication,Info,RD0003FF410F59,2984,1,,Application_Start,"
It is escaped, and fits entirely in the CSV column, which I wouldn't wish. Any idea if there is something to do about this?