Roots Discourse

How to use facades in roots sage?

I want to use the logger registered in config/app.php

    'aliases' => [
        'Log' => Illuminate\Support\Facades\Log::class,

however, it doesn’t work the same way than laravel.

What’s the correct way of using those facades?

This doesn’t work:

use Log;
Log::debug('An informational message.');

I believe you need to include the Log class in your PHP file like this:

use Illuminate\Support\Facades\Log;

And then check the application logs at your-sage-dir/storage/logs. Output should go there.

Thanks, now I get:

Fatal error : Uncaught RuntimeException: A facade root has not been set.

If I use this code in bootstrap/app.php

use Illuminate\Support\Facades\Log;

But this works:

use Illuminate\Support\Facades\Log;
add_filter('init', function () {
    return Log::debug('test');

Any ideas why?

My guess: probably that’s just not where that function is intended to be used.