0

A Laravel project is working locally well but fails when deployed to an EC2 instance using ElasticBeanstalk. The error is:

PHP Fatal error:  Uncaught Error: Class 'Log' not found in /var/app/current/app/Exceptions/Handler.php:35\nStack trace:\

The content of that line is \Log::error($e);

I've tried the following.

use Illuminate\Support\Facades\Log;

    class Handler extends ExceptionHandler
    {
        ...

        public function report(Exception $e)
        {
            ...

            {
                Log::error($e);
            }

        }

With this, I get a new error of: PHP Fatal error: Uncaught RuntimeException: A facade root has not been set.

I also tried use Log but got an error PHP Fatal error: Uncaught Error: Class 'Log' not found.

Both these fails:

use Illuminate\Support\Facades\Log;

    class Handler extends ExceptionHandler
    {
        ...

        public function report(Exception $e)
        {
            ...

            {
                Log::error($e);
            }

        }
class Handler extends ExceptionHandler
    {
        ...

        public function report(Exception $e)
        {
            ...

            {
                \Log::error($e);
            }

        }

I didn't expect this error. My expectation was that Laravel already has this class.

Ps: I'm new to Laravel.

learnc
  • 43
  • 1
  • 5

1 Answers1

0

use

\Log::info($e);

i hope it helps.

Vipul Prajapati
  • 203
  • 2
  • 4