Access App Logs in Shopify CLI: Debug Custom Apps

Learn how to access app logs in Shopify CLI to debug custom Shopify apps. Stream logs, filter errors, and fix common issues in webhooks and API calls.

Access App Logs in Shopify CLI: Debug Custom Apps

To access app logs in Shopify CLI, run shopify app dev and watch the terminal output, or use shopify app logs for deployed apps. This guide shows you how to read those logs, filter them, and fix common errors in custom Shopify apps.

Shopify CLI is the command-line tool for building Shopify apps. When you run your app locally with shopify app dev, the CLI streams logs from your app server and from Shopify's platform. These logs are your first stop when debugging webhooks, API calls, or app proxies. But they only show what your app and Shopify emit—not the internal state of your database or third-party services. Understanding what's included (and what's not) saves hours.

If you're building a custom Shopify app and need help with logging, monitoring, or the app itself, our team at Digital Executive Partner can assist.

What Shopify CLI app logs actually show (and what they don't)

When you run shopify app dev, the CLI starts your app and tunnels it to Shopify. Logs appear in your terminal and include:

  • HTTP requests to your app's backend (method, path, status code, response time).
  • Webhook deliveries from Shopify to your app (topic, payload, response status).
  • GraphQL and REST API calls your app makes to Shopify (operation name, variables, response status).
  • Errors from your app server (stack traces, unhandled exceptions).
  • CLI messages about tunnel status, environment variables, and app installation.

What they don't show:

  • Database queries or internal application state unless your app logs them.
  • Third-party service logs (e.g., payment gateways, email providers).
  • Shopify's internal processing beyond what's returned in API responses.
  • Logs from other environments (staging, production) unless you explicitly connect to them.

So while Shopify CLI gives you a real-time view of app-Shopify interactions, you still need application-level logging for full observability.

Streaming logs for a running dev server vs. production app logs

Dev server logs

When you run shopify app dev, logs stream to your terminal by default. You can also open the Shopify CLI dev console in your browser (usually at http://localhost:3456) for a more structured view. The dev console shows the same logs but with filtering and search.

To stream logs from a dev server that's already running, use:

shopify app dev --reset

This restarts the dev server and streams logs. If you only want logs without restarting, you can't—Shopify CLI attaches logging to the dev process. For production apps, use shopify app logs.

Production app logs

For apps deployed to Shopify's infrastructure (e.g., via shopify app deploy), use:

shopify app logs --store your-store.myshopify.com

This streams logs from your deployed app. You can filter by log level:

shopify app logs --store your-store.myshopify.com --level error

Available levels: debug, info, warn, error. By default, all levels are shown.

Note: shopify app logs only works for apps hosted on Shopify's platform (e.g., using Shopify Functions or extensions). For apps hosted elsewhere (e.g., your own server), you need to use your hosting provider's logging tools.

Laptop on a wooden table

Filtering and tracing errors across webhooks and API calls

Shopify CLI logs can be noisy. Use these techniques to focus on what matters:

  • Filter by log level: As shown above, use --level error to see only errors.
  • Search in the dev console: The browser-based dev console has a search bar. Type a webhook topic (e.g., orders/create) or an API operation name to filter.
  • Trace a single request: Each log entry includes a request ID. Search for that ID to follow a request across your app and Shopify.
  • Watch for webhook failures: Webhooks that return non-2xx status codes are logged with the response body. Look for Webhook failed messages.
  • Monitor API rate limits: Shopify returns 429 status codes when you exceed rate limits. The logs show these with headers like Retry-After.

For deeper tracing, add structured logging to your app (e.g., using Winston or Pino in Node.js) and include the Shopify request ID in your logs. Then you can correlate CLI logs with your own.

Common log errors in custom apps and how to fix them

Here are frequent errors you'll see in Shopify CLI logs and how to resolve them:

Error message Likely cause Fix
Invalid API key or access token Wrong credentials in .env or app configuration Check shopify.app.toml and environment variables. Reinstall the app if needed.
Webhook verification failed Incorrect webhook secret or missing HMAC validation Ensure your app validates the X-Shopify-Hmac-Sha256 header using the app's shared secret.
429 Too Many Requests Exceeded Shopify API rate limits Implement exponential backoff and respect the Retry-After header.
GraphQL error: Field 'X' doesn't exist Using an outdated API version or wrong field name Check the API version in your app and update queries to match the schema.
App proxy request failed Misconfigured proxy URL or authentication Verify the proxy URL in shopify.app.toml and ensure your app handles proxy requests.
Tunnel not found The ngrok tunnel used by shopify app dev has expired or failed Restart shopify app dev to create a new tunnel.

For webhook verification, here's a minimal Node.js example:

const crypto = require('crypto');

function verifyWebhook(body, hmac, secret) {
  const hash = crypto.createHmac('sha256', secret).update(body, 'utf8').digest('base64');
  return crypto.timingSafeEqual(Buffer.from(hash), Buffer.from(hmac));
}

Always use a timing-safe comparison to prevent timing attacks.

When to build in logging and monitoring for a production app

Shopify CLI logs are great for development, but production apps need more:

  • Persistent storage: CLI logs are ephemeral. Use a logging service (e.g., Loggly, Datadog, Papertrail) to store logs.
  • Alerting: Set up alerts for error spikes, webhook failures, or rate limit breaches.
  • Performance monitoring: Track response times and API call latency.
  • Audit trails: Log critical actions (e.g., order modifications) for compliance.

If you're building a custom Shopify app, plan for logging from day one. At Digital Executive Partner, we build Shopify apps with robust logging and monitoring baked in. Contact us to discuss your project.

Checklist: Debugging with Shopify CLI logs

  • Run shopify app dev and open the dev console.
  • Filter logs by level (--level error).
  • Search for webhook topics or API operation names.
  • Correlate request IDs across logs.
  • Add structured logging to your app for production.
  • Set up alerts for critical errors.

By following these steps, you'll spend less time guessing and more time fixing.

Related reading

FAQ

Frequently asked questions

How do I access app logs in Shopify CLI?

Run shopify app dev to stream logs from your local dev server, or shopify app logs for deployed apps. Use --level to filter by log level.

What's the difference between `shopify app dev` and `shopify app logs`?

shopify app dev runs your app locally and streams logs from the dev server and Shopify. shopify app logs streams logs from a deployed app hosted on Shopify's platform.

Can I see production logs with Shopify CLI?

Yes, if your app is deployed to Shopify's infrastructure. Use shopify app logs --store your-store.myshopify.com. For apps hosted elsewhere, use your hosting provider's logging.

Why are my webhooks failing in the logs?

Common causes include incorrect webhook secret, missing HMAC validation, or your app returning non-2xx status. Check the log entry for the response body and verify your webhook handler.

How do I filter logs by log level?

Use the --level flag with shopify app logs, e.g., --level error. Available levels: debug, info, warn, error.

Do Shopify CLI logs include database queries?

No, they only show app-Shopify interactions and server errors. Add application-level logging to capture database queries and internal state.

Need help debugging your Shopify app?

Our team builds and maintains custom Shopify apps with robust logging and monitoring. Let's make your app easier to debug.