{
    "url": "https://delaparra-services.nl/manuals/logging-en-monitoring",
    "locale": "en",
    "title": "Logging and monitoring for your app · DeLaParra Services",
    "description": "Writing and reading logs in Laravel, receiving error notifications via Sentry, monitoring uptime, and what SLA, SLO, latency and p95 mean for a small app.",
    "alternates": {
        "en": "https://delaparra-services.nl/manuals/logging-en-monitoring",
        "nl": "https://delaparra-services.nl/nl/handleidingen/logging-en-monitoring"
    },
    "formats": {
        "csv": "https://delaparra-services.nl/manuals/logging-en-monitoring.csv",
        "md": "https://delaparra-services.nl/manuals/logging-en-monitoring.md",
        "json": "https://delaparra-services.nl/manuals/logging-en-monitoring.json",
        "zip": "https://delaparra-services.nl/manuals/logging-en-monitoring.zip",
        "pdf": "https://delaparra-services.nl/manuals/logging-en-monitoring.pdf"
    },
    "downloads": [
        {
            "url": "https://delaparra-services.nl/manuals/logging-en-monitoring.csv",
            "encodingFormat": "text/csv",
            "name": "logging-en-monitoring.csv"
        },
        {
            "url": "https://delaparra-services.nl/manuals/logging-en-monitoring.json",
            "encodingFormat": "application/json",
            "name": "logging-en-monitoring.json"
        },
        {
            "url": "https://delaparra-services.nl/manuals/logging-en-monitoring.md",
            "encodingFormat": "text/markdown",
            "name": "logging-en-monitoring.md"
        },
        {
            "url": "https://delaparra-services.nl/manuals/logging-en-monitoring.pdf",
            "encodingFormat": "application/pdf",
            "name": "logging-en-monitoring.pdf"
        },
        {
            "url": "https://delaparra-services.nl/manuals/logging-en-monitoring.zip",
            "encodingFormat": "application/zip",
            "name": "logging-en-monitoring.zip"
        }
    ],
    "markdown": "# Logging and monitoring for your app\n\nOnce your app is live, you want to know if something is going wrong before a customer calls. This requires three things: **logs** (what happened), **error messages** (something went wrong) and **monitoring\n\n## 1. Logs in Laravel\n\nBy default, Laravel writes to `storage/logs/laravel.log`. To log something yourself:\n\n```php\nuse Illuminate\\Support\\Facades\\Log;\n\nLog::info('Factuur verstuurd', ['factuur_id' => $factuur->id]);\nLog::warning('Betaling vertraagd', ['order' => $order->id]);\nLog::error('PDF maken mislukt', ['exception' => $e]);\n```\n\nTips:\n\n- Provide context as an array, rather than pasting it into the text. That way, you can search it (**structured logging**).\n- **Never** log passwords, tokens or full credit card or national insurance number details.\n- Set `LOG_CHANNEL=daily` in production so that a new file is created every day and old files are deleted.\n\n## 2. Error messages with Sentry\n\nWith a service such as **Sentry**, you’ll receive an email or notification containing the full stack trace as soon as an error occurs in production.\n\n```bash\ncomposer require sentry/sentry-laravel\nphp artisan sentry:publish --dsn=https://jouw-dsn@sentry.io/123\n```\n\nAny uncaught errors are then automatically reported. The **sentry-php-sdk** skill helps your assistant with the entire installation process.\n\n## 3. Monitoring uptime\n\nSet up an external service to check your site every minute. You’ll receive a notification if it doesn’t respond. By default, Laravel has a health route at `/up` that you can use for this.\n\n## 4. Metrics: how healthy is your app?\n\nFor larger apps, you can collect **metrics** (time-series data) using tools such as Prometheus and Grafana, or your cloud provider’s monitoring service. The four **golden signals**:\n\n| Signal | Question |\n|---|---|\n| Latency | How quickly does the app respond? |\n| Traffic | How many requests are coming in? |\n| Errors | How many go wrong? |\n| Saturation | How busy are the CPU, memory and database? |\n\nWhen looking at speed, focus on **percentiles**, not the average. **p95 = 300 ms\n\n## 5. SLA, SLO and SLI in plain language\n\n- **SLI** (indicator): what you measure, e.g. ‘percentage of error-free requests’.\n- **SLO** (target): what you aim to achieve internally, e.g. “99.9% error-free per month”.\n- **SLA** (agreement): what you contractually promise the customer, usually lower than your SLO.\n- **Error budget:** the amount of time that can be lost. 99.9 per cent per month equates to approximately 43 minutes of downtime.\n\nFor a small app, a simple objective is enough: “the site is accessible 99.5 per cent of the time and any faults are investigated within one working day”.\n\n## 6. If things go wrong\n\n1. Confirm the issue (uptime alert, Sentry, logs).\n2. First restore the system (revert to the previous version), then identify the cause.\n3. Write down briefly what happened and what you’re going to change to make sure it doesn’t happen again. The ‘**post-mortem writing**’ skill can help with this.\n\nKey metrics: **MTTD** (how quickly do you notice the issue), **MTTR** (how quickly is it resolved).\n\n## Need help?\n\nMonitoring is an essential part of a well-delivered app. I take care of this at **Custom Software and Web Applications**. Would you like me to look into recurring errors? Take a look at **AI Code Review**.\n\n## Skills\n\n- [Sentry PHP SDK] (/nl/skills/sentry-php-sdk)\n- [Prometheus Configuration] (/nl/skills/prometheus-configuration)\n- [Grafana Dashboards] (/nl/skills/grafana-dashboards)\n- [Distributed Tracing] (/nl/skills/distributed-tracing)\n- [SLO Implementation] (/nl/skills/slo-implementation)\n- [AWS CloudWatch Investigation Skill] (/nl/skills/aws-cloudwatch-investigation)\n- [Incident Runbook Templates] (/nl/skills/incident-runbook-templates)\n- [Postmortem Writing] (/nl/skills/postmortem-writing)\n\n## Related services\n\n- [Maatwerk software en webapplicaties] (/nl/services#service-03)\n- [Beoordeling van AI-code] (/nl/services#service-05)\n\n",
    "structured_data": {
        "@context": "https://schema.org",
        "@graph": [
            {
                "@type": "TechArticle",
                "@id": "https://delaparra-services.nl/manuals/logging-en-monitoring#article",
                "url": "https://delaparra-services.nl/manuals/logging-en-monitoring",
                "headline": "Logging and monitoring for your app",
                "description": "Writing and reading logs in Laravel, receiving error notifications via Sentry, monitoring uptime, and what SLA, SLO, latency and p95 mean for a small app.",
                "inLanguage": "en",
                "subjectOf": {
                    "@id": "https://delaparra-services.nl/manuals/logging-en-monitoring#dataset"
                }
            },
            {
                "@type": "Dataset",
                "@id": "https://delaparra-services.nl/manuals/logging-en-monitoring#dataset",
                "name": "Logging and monitoring for your app",
                "description": "Writing and reading logs in Laravel, receiving error notifications via Sentry, monitoring uptime, and what SLA, SLO, latency and p95 mean for a small app.",
                "url": "https://delaparra-services.nl/manuals/logging-en-monitoring",
                "identifier": "https://delaparra-services.nl/manuals/logging-en-monitoring#dataset",
                "about": {
                    "@id": "https://delaparra-services.nl/manuals/logging-en-monitoring#article"
                },
                "publisher": {
                    "@type": "Organization",
                    "name": "DeLaParra Services",
                    "url": "https://delaparra-services.nl/"
                },
                "isAccessibleForFree": true,
                "inLanguage": "en",
                "isPartOf": {
                    "@type": "Dataset",
                    "@id": "https://delaparra-services.nl/manuals#dataset",
                    "name": "Manuals for working on your own app",
                    "url": "https://delaparra-services.nl/manuals"
                },
                "includedInDataCatalog": {
                    "@type": "DataCatalog",
                    "@id": "https://delaparra-services.nl/knowledge-hub#catalog",
                    "name": "Knowledge hub data catalog",
                    "url": "https://delaparra-services.nl/knowledge-hub"
                },
                "distribution": [
                    {
                        "@type": "DataDownload",
                        "name": "logging-en-monitoring.csv",
                        "encodingFormat": "text/csv",
                        "contentUrl": "https://delaparra-services.nl/manuals/logging-en-monitoring.csv",
                        "inLanguage": "en"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "logging-en-monitoring.json",
                        "encodingFormat": "application/json",
                        "contentUrl": "https://delaparra-services.nl/manuals/logging-en-monitoring.json",
                        "inLanguage": "en"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "logging-en-monitoring.md",
                        "encodingFormat": "text/markdown",
                        "contentUrl": "https://delaparra-services.nl/manuals/logging-en-monitoring.md",
                        "inLanguage": "en"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "logging-en-monitoring.pdf",
                        "encodingFormat": "application/pdf",
                        "contentUrl": "https://delaparra-services.nl/manuals/logging-en-monitoring.pdf",
                        "inLanguage": "en"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "logging-en-monitoring.zip",
                        "encodingFormat": "application/zip",
                        "contentUrl": "https://delaparra-services.nl/manuals/logging-en-monitoring.zip",
                        "inLanguage": "en"
                    }
                ]
            }
        ]
    }
}