Reputation: 71
I am at a loss, I can't find anyone else having this issue so it feels like I'm missing something obvious, but I cannot figure it out. When I attempt to log to a specific channel in Laravel (Reference Here) using
Log::channel('a channel')->info('a message');
I get:
PHP Error: Call to undefined method Illuminate/Log/Writer::channel()
Upvotes: 3
Views: 4197
Reputation: 927
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
$logger = new Logger('channel-name');
$logger->pushHandler(new StreamHandler(__DIR__.'/app.log', Logger::DEBUG));
$logger->info('This is a log! ^_^ ');
$logger->warning('This is a log warning! ^_^ ');
$logger->error('This is a log error! ^_^ ');
this is worked for me in laravel.
Upvotes: 0
Reputation: 71
I'm a dufus. I THOUGHT I had upgraded to 5.6, but I didn't actually save the composer file before I ran the update :/
ACTUALLY Upgraded to 5.6 and no longer getting the error.
Upvotes: 1
Reputation: 1443
Maybe you got the import wrong.
Did you try importing use Illuminate\Support\Facades\Log;
?
Upvotes: 2