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

本文涉及的产品
日志服务 SLS,月写入数据量 50GB 1个月
简介: 【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.");
        }
    }
}
相关实践学习
日志服务之使用Nginx模式采集日志
本文介绍如何通过日志服务控制台创建Nginx模式的Logtail配置快速采集Nginx日志并进行多维度分析。
相关文章
|
9天前
【Azure Policy】分享Policy实现对Azure Activity Log导出到Log A workspace中
在Policy Rule部分中,选择资源的类型为 "Microsoft.Resources/subscriptions", 效果使用 DeployIfNotExists (如果不存在,则通过修复任务进行修正。 在 existenceCondition 条件中,如果当前订阅已经启用了 diagnostic setting并且输出日志到同一个Log A workspace,表示满足Policy要求,不需要进行修正。 在 deployment 中,使用了 ARM 模板, 为订阅添加Diagnostic Setting并且所有的日志Category均启用。
|
20天前
|
Kubernetes 数据安全/隐私保护 容器
【Azure APIM】APIM Self-Hosted网关中,添加网关日志以记录请求头信息(Request Header / Response Header)
【Azure APIM】APIM Self-Hosted网关中,添加网关日志以记录请求头信息(Request Header / Response Header)
|
20天前
[Azure Developer]把Azure Function中ILogger对象静态化为静态方法提供日志记录
[Azure Developer]把Azure Function中ILogger对象静态化为静态方法提供日志记录
|
20天前
【Azure Function & Application Insights】在Azure Function的日志中,发现DrainMode mode enabled Traces。它是什么意思呢?
【Azure Function & Application Insights】在Azure Function的日志中,发现DrainMode mode enabled Traces。它是什么意思呢?
|
20天前
|
存储 大数据 索引
【Azure Contianer Apps】在云上使用容器应用时收集日志遇见延迟问题
【Azure Contianer Apps】在云上使用容器应用时收集日志遇见延迟问题
|
20天前
【Azure Function & Application Insights】调用Function上传和下载文件,有时候遇见大于1MB的文件的日志没有记录在Application Insights中
【Azure Function & Application Insights】调用Function上传和下载文件,有时候遇见大于1MB的文件的日志没有记录在Application Insights中
|
20天前
|
网络安全
【Azure Service Bus】启用诊断日志来获取客户端访问Azure Service Bus的IP地址 [2024-03-26 实验结果失败]
【Azure Service Bus】启用诊断日志来获取客户端访问Azure Service Bus的IP地址 [2024-03-26 实验结果失败]
|
20天前
|
存储
【Azure Log A workspace】Azure上很多应用日志收集到Log A workspace后如何来分别各自的占比呢?
【Azure Log A workspace】Azure上很多应用日志收集到Log A workspace后如何来分别各自的占比呢?
|
20天前
|
存储 Kubernetes API
【APIM】Azure API Management Self-Host Gateway是否可以把请求的日志发送到Application Insights呢?让它和使用Azure上托管的 Gateway一样呢?
【APIM】Azure API Management Self-Host Gateway是否可以把请求的日志发送到Application Insights呢?让它和使用Azure上托管的 Gateway一样呢?
|
20天前
|
Kubernetes Shell 网络安全
【Azure K8S】记录AKS VMSS实例日志收集方式
【Azure K8S】记录AKS VMSS实例日志收集方式