Hi Tommy Paulsen,
Thanks for the question and using MS Q&A platform.
When running a Next.js application on Azure Static Web Apps, accessing server-side logs directly is limited.
- In the Azure portal, create an Application Insights resource. Navigate to your Static Web App, select Configuration, and add a new application setting named
APPINSIGHTS_INSTRUMENTATIONKEY
with your Application Insights Instrumentation Key as the value. - In the Azure portal, go to your Static Web App's associated Application Insights resource.
- Use the Logs feature to query and analyze your application's telemetry data.
- Use the Application Insights JavaScript SDK to capture client-side logs.
- Install the SDK in your Next.js project
npm install @microsoft/applicationinsights-web
- Initialize and configure the SDK in your application to track client-side events and metrics.
- Use the Azure Static Web Apps CLI to emulate the Azure environment locally, allowing you to view console logs during development.
- Install the CLI
npm install -g @azure/static-web-apps-cli
- Start the emulator
swa start
It enables you to debug and view logs in your local development environment. https://learn.microsoft.com/en-us/azure/static-web-apps/monitor?utm_source=chatgpt.com
DEV Community
https://learn.microsoft.com/en-us/azure/static-web-apps/deploy-nextjs-hybrid?utm_source=chatgpt.com
By integrating Application Insights and utilizing local development tools, you can effectively monitor and debug your Next.js application on Azure Static Web Apps.
If the answer is helpful, please click Accept Answer and kindly upvote it so that other people who faces similar issue may get benefitted from it.