MANUAL

Logging and monitoring for your app

Logging and monitoring for your app

Once 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

01

1. Logs in Laravel

By default, Laravel writes to storage/logs/laravel.log. To log something yourself:

use Illuminate\Support\Facades\Log;

Log::info('Factuur verstuurd', ['factuur_id' => $factuur->id]);
Log::warning('Betaling vertraagd', ['order' => $order->id]);
Log::error('PDF maken mislukt', ['exception' => $e]);

Tips:

02

2. Error messages with Sentry

With 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.

composer require sentry/sentry-laravel
php artisan sentry:publish --dsn=https://jouw-dsn@sentry.io/123

Any uncaught errors are then automatically reported. The sentry-php-sdk skill helps your assistant with the entire installation process.

03

3. Monitoring uptime

Set 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.

04

4. Metrics: how healthy is your app?

For 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:

Signal Question
Latency How quickly does the app respond?
Traffic How many requests are coming in?
Errors How many go wrong?
Saturation How busy are the CPU, memory and database?

When looking at speed, focus on percentiles, not the average. **p95 = 300 ms

05

5. SLA, SLO and SLI in plain language

For 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”.

06

6. If things go wrong

  1. Confirm the issue (uptime alert, Sentry, logs).
  2. First restore the system (revert to the previous version), then identify the cause.
  3. 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.

Key metrics: MTTD (how quickly do you notice the issue), MTTR (how quickly is it resolved).

07

Need help?

Monitoring 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.

08

Skills

09

Related services