Amir Bar
Amir Bar

Reputation: 3105

log every laravel action that happen?

where is the appropriate place to catch every time laravel is used even non http based action?

I want to catch everything even artisan commands, Queues or Task that running.

the only place I can think of is bootstrap\app.php but its too hacky and with my experience with laravel I am sure there is some built in way of doing it

is there some one place to catch them all?

Upvotes: 0

Views: 78

Answers (1)

bubjavier
bubjavier

Reputation: 1012

you can add your logger to your app/Providers/AppServiceProvider.php's boot() function.

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        // Your logger goes here
        error_log('log...');
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}

Upvotes: 1

Related Questions