【发布时间】: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 容器。
有什么想法吗?
【问题讨论】:
-
github.com/JDetmar/NLog.Extensions.AzureStorage/blob/master/src/… 看起来很奇怪。它可能应该是
container而不是_container(确实尚未初始化)
标签: azure nlog asp.net-core-2.2