我已啓用診斷日誌記錄到Azure網站的Blob存儲我正在嘗試。我還設置了Nlog寫入Trace
,然後將它們寫入Azure blob。 Nlog佈局設置爲CSV。這可以工作,並將生成的日誌輸出到blob存儲。如果這是記錄到傳統文件,該文件將是一個CSV文件,我可以在Excel中打開,以更好地分析日誌文件。將nlog生成的日誌存儲到Azure Blob存儲中,單獨列
NLOG配置文件複製如下:
<?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的診斷保存診斷信息作爲Blob存儲的CSV文件。 CSV文件具有以下列。
date,level,applicationName,instanceId,eventTickCount,eventId,pid,tid,message,activityId
但是,整個NLog消息寫入Message
列。這可能是因爲它在那裏保存了Diagnostics.Trace
消息,其中NLog正在保存它的日誌。例如:
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,",
的NLOG消息是如下:
"2014-05-07,12:18:49.6254,TestAzureWebApplication1.MvcApplication,Info,RD0003FF410F59,2984,1,,Application_Start,"
據逃出來了,完全在CSV列,這是我不希望配合。任何想法,如果有什麼關係呢?
@GuaravMantri我會通過博客文章。但是,它是否將來自不同實例的日誌文件合併到一個Blob文件中? –
不,它不。每個實例都將自己的日誌文件寫入blob存儲中。你可以做的是有一個後臺進程結合起來,或者可以解析它並將其推入表存儲。 –
我不確定如果「正常」的Azure診斷實際上是否合併它們,我需要重新確認一次有多個實例。再次,合併它們將是一個小問題。 –