【发布时间】:2021-03-14 13:49:33
【问题描述】:
我在 Azure API 管理中有以下策略。它工作得很好:
<return-response>
<set-status code="302" />
<set-header name="Location" exists-action="override">
<value>@{
try
{
// ... doing something here that might throw an Exception
return "http://example.com";
}
catch (Exception e)
{
// If something failed, it is usually because of an transient error. Then we just send the user to the same URL again to retry.
return "/";
}
}</value>
</set-header>
</return-response>
现在我想在 Catch 块中记录/trace 一条消息。基本上是这样的,但这当然行不通。
catch (Exception e)
{
<trace source="MyApi" severity="error">
<message>Error foo</message>
<metadata name="ErrorMessage" value="@(e.Message)"/>
</trace>
return "/";
}
如何执行此操作或如何将日志发送到连接的 Application Insights 实例?
【问题讨论】:
-
您还对解决方案感兴趣吗?
-
当然@KaiWalter :)
标签: azure azure-api-management