小编Alv*_*ero的帖子

我在 Azure 日志流中看不到日志

我正在尝试记录我的 ASP.NET Core 应用程序的信息,但我找不到在 Azure 日志流中显示 loogs 的方法。当我在 Visual Studio 中调试时,应用程序成功记录日志,但在发布到 Azure 时看不到任何内容。

这是我的应用服务日志的样子: 应用服务日志

我尝试使用我在 Microsoft 文档中找到的不同方法进行登录,但都没有奏效。

    [HttpGet]
    public string Index()
    {
        Trace.TraceInformation("You are in the face recognition controller. Trace");
        _logger.LogInformation("You are in the face recognition controller. Logger");
        return "You are in the face recognition controller";
    }
Run Code Online (Sandbox Code Playgroud)

控制器构造函数:

    private readonly ILogger _logger;
    public FaceRecognitionController(ILoggerFactory loggerFactory)
    {
        _logger = loggerFactory.CreateLogger<FaceRecognitionController>();
    }
Run Code Online (Sandbox Code Playgroud)

配置方法:

public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }

        loggerFactory.CreateLogger("console");
        loggerFactory.CreateLogger("debug");

        app.UseHttpsRedirection();

        app.UseRouting(); …
Run Code Online (Sandbox Code Playgroud)

c# logging azure azure-web-app-service asp.net-core-3.1

4
推荐指数
1
解决办法
1654
查看次数