Azure App Service Not Displaying Next.js Server Component Logs

Joel Lozano 0 Reputation points
2024-12-18T22:23:19.24+00:00

I've deployed my Next.js (Node.js + React.js) app to Azure App Service (Linux), and I noticed that console.logs aren't being displayed in the Azure Log Monitor. If an error occurs in an API route, I can see the error output in the Log Monitor, but I can't see any logs from my own code. I've been trying to set up Azure Application Insights to receive the logs to work around the issue, but I can't get that to work in the cloud, although it works in my local Windows environment (I can send logs to App Insights and view them in the portal). I'm not sure, but thinking these issues may be related.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,930 questions
{count} votes

1 answer

Sort by: Most helpful
  1. brtrach-MSFT 17,731 Reputation points Microsoft Employee Moderator
    2025-01-04T07:48:18.3633333+00:00

    @Joel Lozano ensure that Application Logging (Filesystem) is enabled in the Azure Portal under your App Service's Diagnostics settings, and verify that the Log Level is set to the appropriate level (e.g., Information or Verbose). Use the Log Stream feature in the Azure Portal to view real-time logs, and check the LogFiles directory in your App Service's file system via the Kudu Console for any logs under /home/LogFiles. For Application Insights, double-check the instrumentation key and configurations in your next.config.js or environment variables, and ensure the SDK is initialized correctly in your application code. Sometimes, logs might not appear due to buffering issues, so try flushing the logs explicitly in your code. Finally, restart your App Service and redeploy your application to ensure all configurations are applied correctly.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.