Nlog json 配置问题 'AsyncWrapper Target[xxx]()' 上的必需参数 'WrappedTarget' 未指定

Nlog json cofiguration problem Required parameter 'WrappedTarget' on 'AsyncWrapper Target[xxx]()' was not specified

 <target name="asyncAsb" xsi:type="AsyncWrapper">
            <target
                name="asb"
                type="AzureServiceBus"
                connectionString="xxx"
                queue="logs_queue" />
        </target>

尝试通过 json 像这样设置

"asyncAsb": {
                    "type": "AsyncWrapper",

                    "targets": {
                        "asb": {
                            "type": "AzureServiceBus",
                            "connectionString": "xxx",
                            "queue": "monitor_queue"
                        }
                    }
                },

但出现错误 "Required parameter 'WrappedTarget' on 'AsyncWrapper TargetasyncAsb' was not specified."

有人有这部分的例子吗?

我想我们正在谈论 https://github.com/NLog/NLog.Extensions.Logging 允许使用 JSON appsettings.json 配置文件配置 NLog 的项目。

从他们的示例 https://github.com/NLog/NLog.Extensions.Logging/blob/master/examples/NetCore2/ConsoleExampleJsonConfig/appsettings.json 中,我们可以看到您的案例的以下语法:

"targets": {
  "asyncAsb": {
    "type": "AsyncWrapper",
    "target": {
      "asb": {
        "type": "AzureServiceBus",
        "connectionString": "xxx",
        "queue": "monitor_queue"
      }
  }
}
}