azure-functions - 在 Azure 上的何处可以找到 FunctionsStartup.Configure 中引发的异常记录?

标签 azure-functions error-logging azure-functions-runtime

在下面的代码中,错误记录在Azure中的什么地方?有时这种错误的原因很难确定,导致“Function host is not running.”,我已经无法找到记录的异常。

我之前通过自己编写自己的 try/catch 日志记录到 BlobStorage 来解决这个问题,但是,我希望有一种更惯用的方法来获取异常。

public class Startup : FunctionsStartup
{
    public override void Configure(IFunctionsHostBuilder builder)
    {
        throw new Exception("Boom!");

        ConfigureServices(builder.Services);
    }
...

我查看了以下地方:

诊断和解决问题/功能 App Down 或报告错误:

  • 报告一个过时的错误,每次出现上述错误时似乎都没有更新。

应用洞察:

  • “您的应用已离线或 Application Insights SDK 需要更新。”

捻角羚:

  • D:\home\LogFiles\eventlog.xml - 在这里看不到任何有意义的东西
  • D:\home\LogFiles\Application\Functions\Function\FunctionName\*.log - 今天没有文件
  • D:\home\LogFiles\Application\Functions\Host\*.log - 今天没有文件

存储帐户文件共享:

  • 一个修改为今天的日期
  • /LogFiles/- 空
  • /site/wwwroot/- 空

最佳答案

您可以按照以下步骤从 Startup.cs 检查异常日志。

首先,这是我的测试代码:

[assembly: FunctionsStartup(typeof(FunctionApp11.Startup))]
namespace FunctionApp11
{
    public class Startup: FunctionsStartup
    {
        
        public override void Configure(IFunctionsHostBuilder builder)
        {
            throw new Exception("xxxx haha an error is occuring....");
        }
     
    }
}

在azure portal中运行azure function后,请按以下步骤操作:

第 1 步。导航到 azure 门户 -> 您的函数应用 -> 单击诊断和解决问题 blade -> 然后在搜索框里输入Function app down -> 然后可以看到出现Function App Down or Reporting Errors,点击它。截图如下:

enter image description here

第 2 步Function App Down or Reporting Errors 页面中,展开Function Executions and Errors -> 然后展开Detected在您的函数应用程序中离线托管。 -> 最后,你可以在那里看到异常日志(如果没有错误日志,可以考虑更改页面中的时间范围)。截图如下:

enter image description here

关于azure-functions - 在 Azure 上的何处可以找到 FunctionsStartup.Configure 中引发的异常记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62657579/

相关文章:

c# - 使用 log4net 设置 XmlConfigurator 公共(public)日志记录

c# - 在azure函数V2中将TraceWriter替换为ILogger

node.js - Azure Functions NodeJS Express 应用程序抛出无法确定函数入口点错误

python - 有没有办法使用 VS Code 和 Python 监视 Azure Functions 中的内存消耗?

python - 如何重定向 python 运行时错误?

c# - Azure函数: System. Private.CoreLib:无法加载文件或程序集 'System.ComponentModel.Annotations...'

javascript - 记录来自另一个子域的 javascript 错误

azure - Azure Function App VS 2019 .NET 3.0 中出现错误 - 找不到方法 : 'IFunctionsHostBuilder.get_Services()'

Azure Function CosmosDB 触发器返回编码数据?

azure - 如何使用非默认功能键?