简体   繁体   中英

Laravel Log channel undefined method

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()

Maybe you got the import wrong.

Did you try importing use Illuminate\\Support\\Facades\\Log; ?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM