簡體   English   中英

如何集成NLog以將日志寫入Azure Streaming日志

[英]How to integrate NLog to write log to Azure Streaming log

目前我正在使用NLog將我的應用程序錯誤寫入文本文件。 除了寫入Azure Blob存儲之外,如何配置NLog將錯誤消息寫入Azure Streaming Log?

Azure Streaming Log捕獲發送到Trace接口的內容。 如果將NLog配置為發送到該目標,則可以通過Visual Studio中的輸出窗口輕松訪問該目標。

以下是我配置NLog.config以獲取此結果的方法:

  <targets>
    <target xsi:type="File" name="f" fileName="${basedir}/logs/${shortdate}.log" layout="${longdate} ${uppercase:${level}} ${message} ${exception:format=tostring}" />
    <target xsi:type="Trace" name="trace" layout="${logger} ${message} ${exception:format=tostring}" />
  </targets>

  <rules>
    <logger name="*" minlevel="Info" writeTo="f" />
    <logger name="*" minlevel="Trace" writeTo="trace" />
  </rules>

第一個目標應該類似於您已經記錄到文件的目標,第二個目標只是將數據發送到跟蹤通道。

希望這可以幫助!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM