Sentry
Capture PHP exceptions and error-level logs in Sentry — step-by-step setup and Vortos configuration.
Sentry
Sentry is an error tracking platform. It captures exceptions and error-level events, groups similar errors together, tracks how often they occur, and alerts you when new issues appear. Unlike raw logs, Sentry includes full stack traces, request context, user info, and a web UI for triaging issues.
Vortos connects to Sentry through the logger's alerting handler. Any log record at ERROR level or above is automatically captured as a Sentry issue.
What you need
- A Sentry account (free tier covers most small projects — sentry.io)
- Your Vortos app running with
vortos-loggerinstalled
Step 1 — Create a Sentry project
- Log in to sentry.io and go to Projects → Create Project
- Select PHP as the platform
- Give it a name that matches your app (e.g.
my-app-prod) - Click Create Project
- Copy the DSN shown on the next screen — it looks like:
https://abc123@o123456.ingest.sentry.io/789012
Step 2 — Install the Sentry PHP SDK
composer require sentry/sentry-phpStep 3 — Add the DSN to your environment
SENTRY_DSN=https://abc123@o123456.ingest.sentry.io/789012Never commit this value to version control. Add .env to .gitignore and use your deployment platform's secrets management for production.
Step 4 — Configure Vortos
use Monolog\Level;
use Vortos\Logger\DependencyInjection\VortosLoggingConfig;
return static function (VortosLoggingConfig $config): void {
$config->sentry(
dsn: $_ENV['SENTRY_DSN'] ?? '',
minLevel: Level::Error, // ERROR, CRITICAL, ALERT, EMERGENCY — all captured
);
};If SENTRY_DSN is not set or is an empty string, the handler is silently skipped — no error is thrown. This means the same config file works in development (no DSN set) and production (DSN set).
Step 5 — Verify it's working
Trigger a test error. Add this temporarily to a controller:
$this->logger->error('Sentry test', ['test' => true, 'timestamp' => time()]);Make a request that hits that code, then open your Sentry project. Within 30 seconds you should see a new issue titled "Sentry test" with the context array attached.
Only ERROR and above
INFO and WARNING logs are not sent to Sentry — only ERROR, CRITICAL, ALERT, and EMERGENCY. This is intentional: Sentry's value is in capturing actionable failures, not routine logs. Use Loki or a log aggregator for full log search.
Step 6 — Set up alerts in Sentry
- In your Sentry project, go to Alerts → Create Alert
- Select Issues as the alert type
- Set the condition: e.g. "A new issue is created" or "Number of events > 10 in 1 hour"
- Add notification actions: email, Slack, PagerDuty
- Save
By default Sentry emails the project owner on every new issue. For production, set up a Slack or PagerDuty integration so alerts reach your on-call rotation.
Minimum level
| Level | Captured? |
|---|---|
DEBUG | No |
INFO | No |
NOTICE | No |
WARNING | No |
ERROR | Yes (default threshold) |
CRITICAL | Yes |
ALERT | Yes |
EMERGENCY | Yes |
Change the threshold by passing minLevel:
$config->sentry(dsn: $_ENV['SENTRY_DSN'] ?? '', minLevel: Level::Critical);
// Only CRITICAL and above — useful for very high-traffic appsTroubleshooting
Issues not appearing in Sentry:
- Check that
SENTRY_DSNis set and correct:var_dump($_ENV['SENTRY_DSN']) - Confirm
sentry/sentry-phpis installed:composer show sentry/sentry-php - Check the log level — only ERROR and above are sent
- Check Sentry's project settings for any IP allowlisting
Too many issues (noise):
- Raise the threshold to
Level::Critical - Use Sentry's "ignore" or "resolve" features to filter known non-actionable errors