· 2 min read

Centralised logging for Laravel on shared hosting, with no agent

You can't install Datadog's agent on shared hosting. Here's how to ship Laravel logs, metrics and traces over HTTPS with one token and no extra processes.

Most observability tools assume you control the server: install an agent, run a collector, open a port. On shared hosting you get PHP, a database, a cron entry and an .env file. That is enough — if the tool meets you there.

The constraints

  • No long-running processes. No agent, no sidecar, no queue worker you can rely on.
  • No root. You cannot install system packages or tail /var/log.
  • One PHP request at a time. Whatever ships your logs must not make pages slower, and must never break them.

The approach: send at the end of the request

Instead of writing logs to a file for an agent to pick up, collect them in memory during the request and send one HTTPS call after the response has gone out. Laravel gives you the hook for it: work registered with app()->terminating() (or defer() in Laravel 11+) runs after the response is sent to the browser, so the user never waits for it.

The batch is small JSON: the log lines, the metrics and the spans of that request, each with the request's trace id. A short timeout keeps a slow network from piling up PHP workers, and a try/catch around everything means a monitoring outage can never become your outage.

Wiring it up

With Grafatsuki it is three files and two environment variables:

  1. Download the client, the log handler and the middleware from your app's Setup page (or paste the agent prompt into Claude Code or Cursor and let it do the steps).
  2. Add to .env:
GRAFATSUKI_URL=https://your-garden/api/v1/ingest
GRAFATSUKI_TOKEN=gk_…
  1. Add the log channel to your stack, and register the middleware (in bootstrap/app.php on Laravel 11+).

From then on, every Log::error() goes to the garden with the request's trace id, every request is timed per route, and every SQL query becomes a span in the request's waterfall. Count what matters to the business with one line:

Grafatsuki::increment('orders.placed', ['plan' => $order->plan]);

What about queued jobs and cron?

If you run the queue through the scheduler (queue:work --stop-when-empty every minute, the usual pattern on shared hosting), the client traces each job like a request. For the scheduler itself, add a check-in, so you hear about it when the cron entry disappears.

Keeping it cheap

  • Log at info and above in production; keep debug for local.
  • Put identifiers in the context array, not in the message, so the same error groups into one issue.
  • Set a retention that matches how far back you actually look — two weeks is plenty for most apps.

Shared hosting is not a reason to debug blind. One token and one HTTPS call per request give you logs, metrics and traces in one place. See the setup guide and the logs feature.

laravelloggingshared hosting

Keep reading

Plant your first app in five minutes

Free to start. One link, one token — or one prompt for your coding agent.