gpt4 book ai didi

azure - 是否可以仅将错误日志发送到事件中心?

转载 作者:行者123 更新时间:2023-12-04 09:35:51 25 4
gpt4 key购买 nike

我在 azure apim 中创建了诊断设置并将日志发送到事件中心。

但现在的要求是我只需将错误日志从 azure api 管理传递到事件中心。当前设置将所有成功和失败日志传递到事件中心。

有没有办法在将日志发送到事件中心之前过滤日志或仅记录错误。

最佳答案

为了实现此目的,我将检查响应状态代码,并且仅在 outbound 部分出现错误时发送到 eventhub,例如所有操作策略:

<policies>
<inbound>
<base />
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
<choose>
<when condition="@(context.Response.StatusCode.ToString() >= "400")">
<log-to-eventhub logger-id ="ehLogger">
@(...)
</log-to-eventhub>
</when>
<otherwise>
</otherwise>
</choose>
</outbound>
<on-error>
<base />
<log-to-eventhub logger-id ="ehLogger">
@(...)
</log-to-eventhub>
</on-error>
</policies>

这是针对来自后端的响应错误。如果您指的是请求/策略处理中发生的错误,您只需从 on-error 部分发送。请参阅here了解更多信息。

关于azure - 是否可以仅将错误日志发送到事件中心?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62592555/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com