Enable structured logging, send log messages with attributes, and view them alongside errors in your Sentry dashboard.
Initialize the Sentry SDK with logs enabled. Set your DSN and configure log options to start capturing structured logs from your application.
The code snippet shows how to enable logs and send log messages with the Sentry SDK.
Learn more about Logsimport * as Sentry from "@sentry/nextjs"; Sentry.init({ dsn: "https://examplePublicKey@o0.ingest.sentry.io/0", enableLogs: true, }); Sentry.logger.info("User logged in", { userId: 123 }); Sentry.logger.error("Payment failed", { orderId: "order_123", amount: 99.99 });
Automatically capture console.log, console.warn, and console.error calls as Sentry logs. Add the consoleLoggingIntegration to send existing console calls without changing your code.
import * as Sentry from "@sentry/nextjs"; Sentry.init({ dsn: "https://examplePublicKey@o0.ingest.sentry.io/0", enableLogs: true, integrations: [ Sentry.consoleLoggingIntegration({ levels: ["log", "warn", "error"] }), ], }); console.log("User logged in", { userId: 123 }); console.error("Payment failed", { orderId: "order_123", amount: 99.99 });
View all your logs in Explore > Logs. Search by text string, filter by log level or attributes, and see logs automatically attached to related errors in the Issues view.
Learn more about the Logs viewSend logs to Sentry from platforms where you can't use the Sentry SDKs. Set up log drains to forward logs from your deployments directly to Sentry without code changes. Log drains are available for Vercel, Cloudflare, Heroku, Supabase, and Shopify Hydrogen.
Learn more about log drainsCreate alerts and dashboard widgets from your log data. Set up notifications for critical log patterns, monitor log volumes, and track trends over time to stay ahead of issues.
Learn more about alertsExplore the full documentation to learn more about Logs features and integrations.
