【问题标题】:Why NLog to Azure blob storage doesn't work?为什么 NLog 到 Azure blob 存储不起作用?
【发布时间】:2020-01-22 17:44:48
【问题描述】:

我正在使用 asp.net core 2.2,并希望从将日志写入文件切换到 azure blob 存储。
并且没有写任何斑点。

nlog.config(部分简洁):

 <extensions>
    <add assembly="NLog.Web.AspNetCore"/>
    <add assembly="NLog.Extensions.AzureBlobStorage" />
  </extensions>

 <target xsi:type="AzureBlobStorage" name="azure" 
      container="logs" 
      connectionString="**REMOVED**" 
      blobName="test.log" 
      layout="${longdate}|${event-properties:item=EventId_Id}|${pad:padding=-5:inner=${uppercase:${level}}}|${logger:shortName=true}|${message} ${exception:format=tostring}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action}" />

内部日志:

错误 AzureBlobStorageTarget:无法初始化 blob=test.log in 容器=日志异常:System.NullReferenceException:对象 引用未设置为对象的实例。在 NLog.Targets.BlobStorageTarget.CloudBlobService.InitializeContainer(字符串 containerName, CancellationToken cancelToken) 在 NLog.Targets.BlobStorageTarget.CloudBlobService.InitializeAndCacheBlobAsync(字符串 containerName、字符串 blobName、字符串 contentType、CancellationToken 取消令牌)

尝试了 connectionStringKey 替代方法,结果相同。
我在上述存储帐户中有一个 logs 容器。

有什么想法吗?

【问题讨论】:

标签: azure nlog asp.net-core-2.2


【解决方案1】:

NLog.Extensions.AzureBlobStorage 2.0.1 版本刚刚发布。

【讨论】:

    猜你喜欢
    • 2021-04-30
    • 2021-10-28
    • 2020-12-09
    • 2014-12-13
    • 1970-01-01
    • 2015-04-23
    • 2019-08-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多