我正在尝试将 NLog 与 Azure Web 应用程序一起使用。一切都在我的本地 PC 上运行,但是当我部署到 Azure 时它根本不起作用。我尝试过不同的目标,如文件和 Azure 表存储。两者都可以在我的 PC 上完美运行,但在 Azure 中却不能。我正在使用asp.net核心。这是我的表存储 NLog 配置。注意:当我从本地 PC 执行程序时,此配置有效。我可以看到 Azure 表存储中的条目。<?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" autoReload="true" > <extensions> <add assembly="NLog.Extensions.AzureTableStorage"/> </extensions> <targets> <target xsi:type="AzureTableStorage" name="allfile" PartitionKey="nlog-all-${date}.${logger}" RowKey="${ticks}.${guid}" ConnectionString="**REMOVED**" tableName="**REMOVED**" layout="${longdate}|${logger}|${uppercase:${level}}|${message} ${exception}" /> <target xsi:type="AzureTableStorage" name="ownFile" PartitionKey="nlog-own-${date}.${logger}" RowKey="${ticks}.${guid}" ConnectionString="**REMOVED**" tableName="**REMOVED**" layout="${longdate}|${logger}|${uppercase:${level}}|${message} ${exception}" /> <target xsi:type="Null" name="blackhole" /> </targets> <rules> <!--All logs, including from Microsoft--> <logger name="*" minlevel="Trace" writeTo="allfile" /> <!--Skip Microsoft logs and so log only own logs--> <logger name="Microsoft.*" minlevel="Trace" writeTo="blackhole" final="true" /> <logger name="*" minlevel="Trace" writeTo="ownFile" /> </rules></nlog>
1 回答

慕村9548890
TA贡献1884条经验 获得超4个赞
我注意到配置文件NLog.config在 Azure 中没有更新(或被覆盖)。将配置文件重命名为不同的名称解决了我的问题。但是,我认为这只是一种解决方法。
Azure 中的NLog.config似乎就是一个例子,并且根本不包含任何目标。
- 1 回答
- 0 关注
- 164 浏览
添加回答
举报
0/150
提交
取消