Tun*_*Tse 5 php logging laravel
运行php artisan服务时,laravel如何在控制台上打印出一些字符串?我试过了,Log::info但是没有用。
Goo*_*ian 21
这很简单。
您可以在 APP 中的任何位置调用它。
$out = new \Symfony\Component\Console\Output\ConsoleOutput();
$out->writeln("Hello from Terminal");
Run Code Online (Sandbox Code Playgroud)
Laravel 5.6简化了此操作,因为您现在有了logging.php可以利用的配置文件。
要知道的关键是您要输出到stdoutphp ,并且它具有内置的流包装器php://stdout。鉴于此,您可以为该包装器添加频道。您可以将标准输出“通道”添加到要登录的通道。
这是配置的基本外观:
<?php
return [
'default' => env('LOG_CHANNEL', 'stack'),
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['single','stdout'],
],
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
],
'stdout' => [
'driver' => 'monolog',
'handler' => StreamHandler::class,
'with' => [
'stream' => 'php://stdout',
],
],
];
Run Code Online (Sandbox Code Playgroud)
我在这里有更多信息-Laravel 5.6-写入控制台
| 归档时间: |
|
| 查看次数: |
16221 次 |
| 最近记录: |