countries-laravel
countries-laravel copied to clipboard
Laravel 5.6 causes " Call to undefined method Monolog\Logger::listen()"
I installed it on Laravel 5.6. It gives "Call to undefined method Monolog\Logger::listen()" error
vendor/laravel/framework/src/Illuminate/Log/LogManager.php
* @param array $context
*
* @return void
*/
public function log($level, $message, array $context = [])
{
return $this->driver()->log($level, $message, $context);
}
/**
* Dynamically call the default driver instance.
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public function __call($method, $parameters)
{
return $this->driver()->$method(...$parameters);
}
}
error on this line return $this->driver()->$method(...$parameters);
Getting the same with this.
I'm not able to reproduce it. Could anyone give me a stack trace of this error?
Unfortunately that's the extent of the error it gives me (1 line stack trace). I'll try digging in a little more over the next day or so.
@antonioribeiro: I experienced the same error, and managed to locate the error to something with debugbar and this plugin.
I can reproduce the error on a completely new Laravel 5.6 installation with debugbar and this repo. To recreate the error, try firstly creating a new Laravel 5.6 installation
laravel new test
then install debugbar:
composer require barryvdh/laravel-debugbar --dev
The application should still work. Now install this package using:
composer require pragmarx/countries-laravel
if you go to the frontpage http://test.test, then you should see the following trace:
Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)
Call to undefined method Monolog\Logger::listen()
I hope this helps debugging.
EDIT: I would like to draw your attention to the answer by @kylescousin: https://github.com/barryvdh/laravel-debugbar/issues/812#issuecomment-379248148
From the 5.6 upgrade guide https://laravel.com/docs/5.6/upgrade: "All logging configuration is now housed in its own config/logging.php configuration file. You should place a copy of the default configuration file in your own application and tweak the settings based on your application's needs."
Yeah this package causes the error if installed with the debug bar. Removing either package seems to resolve it.
Anyone had success resolving this?
It's almost certainly just Laravel Debugbar – see my quick fix here.
Steps to reproduce on a clean Laravel install.
composer create-project --prefer-dist laravel/laravel countries
In AppServiceProvider::boot() add
dd([
'LogManager' => get_class($this->app['log']),
'Driver' => get_class($this->app['log']->driver())
]);
Run php artisan and notice by default it should print out.
array:2 [
"LogManager" => "Illuminate\Log\LogManager"
"Driver" => "Illuminate\Log\Logger"
]
Install this package (or the standard one) composer require pragmarx/countries-laravel
Run php artisan again
array:2 [
"LogManager" => "Illuminate\Log\LogManager"
"Driver" => "Monolog\Logger"
]
I can't figure out what's causing it but for some reason the log driver gets changed when this package is installed. Logging was changed in 5.6 so Illuminate\Log\Logger is a wrapper. This then breaks any other packages or Laravel itself if they want to access the logger.
https://github.com/antonioribeiro/countries-laravel/issues/6#issuecomment-386090515
was a fine workaround for me.
As per https://github.com/antonioribeiro/countries-laravel/issues/6#issuecomment-407003331 worked fine on local env.
However, I'm still getting same error on prd where it's supposed there would be no conflict with barryvdh/laravel-debugbar, also having it's config on logs => false.
$ composer install --no-dev
Loading composer repositories with package information
Installing dependencies from lock file
Nothing to install or update
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover
In LogManager.php line 609:
Call to undefined method Monolog\Logger::listen()
Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1
Have the same problem as @alariva on production.