A
A
Anton Shelestov2016-04-18 19:45:00
Laravel
Anton Shelestov, 2016-04-18 19:45:00

How to make logging for each user separately?

Hello.
People tell me how to make sure that the logs (errors and not only) are recorded for each user in their own file.
The only thing that I came up with from the worker is to write this code all the time:

Log::useDailyFiles(storage_path() . '/user_logs/' . Auth::user()->id . '/' . date('Y-m-d') . '.log');
Log::info('Пользователь создал новый проект №' . $id);

But it seems to me that it’s not rational to repeat the same thing everywhere ....
Then I tried to override the ConfigureLogging class, overridden it, but Facades don’t work there, it’s impossible to get an id or a username ((
I was advised somehow through a service provider, I try but I don’t understand how .... I need help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anatoliy Lyovkin, 2016-04-19
@Alyovkin

ActivityLog
packalyst.com/packages/package/spatie/activitylog
Or use Monolog
laravel-tricks.com/tricks/monolog-for-custom-logging

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question