You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure App Service部署的Node.js应用console.log查看方法及输出位置

Hey there! I've got you covered on both questions about Node.js apps running on Azure App Service. Let's dive in.

1. Where does console.log output go in Azure Node.js apps?

When your Node.js app runs on Azure App Service, console.log() (and console.error()) output is captured by the platform and sent to two main destinations:

  • Real-time log stream: Azure streams these logs live as your app generates them.
  • Persistent log files: The logs are saved to your app's file system for later review.

By default, these log files are stored in:

  • For Windows App Service plans: D:\home\LogFiles\Application (look for files like nodejs.log or date-stamped log files)
  • For Linux App Service plans: /home/LogFiles/Application (typically in files named nodejs.log or with timestamps)

These files rotate automatically based on your retention settings to avoid taking up too much storage.

2. How to view console.log content for a deployed Node.js Web App on Azure App Service?

There are several straightforward ways to access these logs, depending on whether you want real-time viewing or to check historical logs:

Option 1: Use the Azure Portal's Log Stream

  • Navigate to your App Service resource in the Azure Portal.
  • From the left menu, under Monitoring, select Log Stream.
  • You'll see a live feed of your app's console.log output, along with other platform logs. You can toggle between "Application logs" and other log types to filter what you see.

Option 2: Access logs via Kudu (SCM) Console

  • Go to https://<your-app-name>.scm.azurewebsites.net (replace <your-app-name> with your actual app's name).
  • From the top menu, select Debug console and choose either CMD (for Windows) or Bash (for Linux).
  • Navigate to the log directory:
    • Windows: Run cd D:\home\LogFiles\Application
    • Linux: Run cd /home/LogFiles/Application
  • To view the latest logs, use commands like:
    • Windows: type nodejs.log
    • Linux: cat nodejs.log
  • You can also download individual log files directly from the Kudu file explorer interface.

Option 3: Use Azure CLI commands

If you prefer working in a terminal:

  • Tail real-time logs: Run az webapp log tail --name <your-app-name> --resource-group <your-resource-group> to stream logs live to your terminal.
  • Download logs to your local machine: Run az webapp log download --name <your-app-name> --resource-group <your-resource-group> to download a zip file containing all your app's logs, which you can open and review locally.

Option 4: Use the App Service Editor

  • In the Azure Portal, go to your App Service resource.
  • Under Development Tools, select App Service Editor and click Go.
  • In the editor, navigate to LogFiles/Application (the full path varies by OS as mentioned earlier).
  • Click on the log file (like nodejs.log) to open and view its contents directly in the browser.

Quick note: Ensure logging is enabled

If you don't see any logs, double-check that application logging is turned on:

  • In the Azure Portal, go to your App Service > App Service logs (under Monitoring).
  • For Application Logging (Filesystem), set the toggle to On, configure a retention period, and save your settings. This ensures logs are persisted to the file system.

内容的提问来源于stack exchange,提问作者developer7788

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 09:37:16