如何在Nlog

时间:2017-03-31 04:54:52

标签: json web-services nlog

使用Nlog 4.4.5上午尝试使用WebService目标的协议JsonPost将日志发布到松弛状态。 Slack webhooks需要通过https帖子(https://api.slack.com/incoming-webhooks

的Json数据
<target xsi:type="WebService"
            name="slack"
            url="https://hooks.slack.com/services/T*****/B4T****/7F********XDv9h/"
            protocol="JsonPost"
            encoding="utf-8"
            >

    <parameter name="text" type="System.String" layout="${date:format=yyyy-MM-dd HH\:mm\:ss.fff}: ${level} - ${message}"/> 

</target>

它没有向我为webhook创建的松弛通道发布任何内容,而我看到我的Nlog.config中的其他目标被调用,日志文件中填充了新数据。

我有什么想法可以解决这个问题吗?

2 个答案:

答案 0 :(得分:1)

也许是这样的回答:

https://github.com/NLog/NLog/issues/1958

在等待解决此问题时(直接使用JSON-Layout):

https://github.com/NLog/NLog/issues/1905

答案 1 :(得分:1)

问题在于Slack webhook网址中的结尾“/”。删除并开始将日志发布到我的松弛频道。