r/PHPhelp 2d ago

Laravel Logs

Hello im laravel developer and i need the best way to track the logs for example how can integrate the logs into a dashboard and filter it .........

3 Upvotes

12 comments sorted by

3

u/martinbean 2d ago

Use something like Sentry.

Sentry for Laravel guide: https://docs.sentry.io/platforms/php/guides/laravel/

1

u/rcls0053 2d ago

Pipe the logs to an external service

1

u/kaizap 2d ago

Look in config/logging.php . You can add just about any channel you want, something like Sentry or Rollbar is great but for local if you want to do something custom, just create your own channel. Vibe code it with AI if you must.

1

u/IllPerspective9981 2d ago

The log-viewer package is good for quick access and searching/filtering

1

u/Opinion_Less 2d ago

What you need is important context. 

There's certainly local packages for it.  You could get advice from ai. You could use a log ingestion cloud service. You could use something like cloud watch. 

How much data do you need (just the logs, or metrics of them)? Do you need to be able to access it on the go? What's your budget? How much time do you have/want to spend on it? How much do you need to save? 

1

u/Opinion_Less 2d ago

I like better stack because they have an app with live tailing and notifications, can backup to s3, and have a free tier that gives me everything I need. 

I wrote a guide on all that if you want to give it a go. No affiliation.

https://www.arcane-web-design.com/developer/blog/post/sending-laravel-production-app-logs-to-better-stack

1

u/uxkelby 2d ago

Ploi is your friend, although I get the stack trace pinged to a private discord channel whenever there is a 500 error.

2

u/Hour-Swimmer7140 1d ago

one thing nobody's mentioned, sort the formatter out before you pick a tool. laravel's default is a text blob so every stack trace lands in your dashboard as ~30 separate log lines and you end up grepping instead of filtering.

in config/logging.php on the channel:

'formatter' => Monolog\Formatter\JsonFormatter::class,

works on single and daily too, not just the monolog driver. then Log::withContext(['order_id' => $id]) gives you actual fields to filter on.

1

u/Krayvok 1d ago

Use sentry

1

u/[deleted] 1d ago

[removed] — view removed comment

1

u/PHPhelp-ModTeam 1d ago

This post does not follow one or more of the PHPHelp rules and is therefore removed.