【Azure 应用服务】当在Azure App Service的门户上 Log Stream 日志无输出,需要如何操作让其输出Application Logs呢?

问题描述

在Azure App Service的门户上 Log Stream 日志无输出,需要如何操作让其输出Application Logs呢?

如下图所示:

问题解答

请注意,上图中提示说:Application logs are switched off.  You can turn them on using the App Service Logs Settings. 应用日志关闭,可以通过App Service Logs 页面来设置开启。

App Service ---> App Service Logs :  针对Application Logging 和 Web Server Logging 为On,最后点击页面上的Save按钮。

保存后,返回Log Stream页面,就可以实时查看App Service中的输出日志:

附录1:.NET API下的日志输出示例

复制代码
using Microsoft.AspNetCore.Mvc;

namespace myapi01.Controllers
{
    [ApiController]
    [Route("[controller]")]
    public class AASController : ControllerBase
    {
        private readonly ILogger<AASController> _logger;
        public AASController(ILogger<AASController> logger)
        {
            _logger = logger;
        }

        [HttpGet]
        [Route("/log")]
        public string GetLog()
        {
            _logger.LogInformation("this is test massge informaiton level!!!!!!!");

            _logger.LogWarning("this is test massge Warning level!!!!!!!");

            _logger.LogError("this is test massge Error level!!!!!!!");

            _logger.LogDebug("this is test massge debug level!!!!!!!");

            _logger.LogCritical("this is test massge Critical level!!!!!!!");

            _logger.LogTrace("this is test massge Trace level!!!!!!!");

            return "Outpu logs - today 2023-04-18 03:56";
        }

        [HttpGet]
        [Route("/exp")]
        public string Getexception()
        {
            throw new Exception("thsi is my custome exception today.");
        }

    }
}
复制代码

 

posted @   路边两盏灯  阅读(116)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
历史上的今天:
2022-04-18 【Azure Fabric Service】怎样关闭 Azure Service Fabric?
点击右上角即可分享
微信分享提示