Home >Backend Development >PHP Tutorial >How to view logs in laravel terminal
This article mainly introduces the method of viewing logs in the terminal of laravel. It has certain reference value. Now I share it with you. Friends in need can refer to it
php artisan tail --path=/Users/henryj/workspace_php/makerlab/app/storage/logs/laravel-2015-04-22.log Instructions to run in mac book terminal
php
The artisan tail
command can be used to view the real-time program running log. It is especially useful when the debug mode is turned off (such as a production environment).
By default tail is only for local code
php artisan tail
When developing, you can also open the LOG of the SQL query statement and use it with php artisan tail
to monitor and control SQL Tuning.
In app/filters.php
add
Event::listen('illuminate.query', function($query, $bindings, $time, $name) { $data = compact('bindings', 'time', 'name'); // Format binding data for sql insertion foreach ($bindings as $i => $binding) { if ($binding instanceof \DateTime) { $bindings[$i] = $binding->format('\'Y-m-d H:i:s\''); } else if (is_string($binding)) { $bindings[$i] = "'$binding'"; } } // Insert bindings into query $query = str_replace(array('%', '?'), array('%%', '%s'), $query); $query = vsprintf($query, $bindings); Log::info($query, $data); });
Next let’s do something Configuration, view the Log in the production environment.
app/config/remote.php
File'connections' => array( 'production' => array( 'host' => '117.111.111.111', // 'username' => 'root', 'password' => '', 'key' => '/Users/username/.ssh/id_rsa', 'keyphrase' => '', 'root' => '/var/webroot', ), ),
You can choose the username and password method for server authentication, or you can set the Key .
配置完成后调用:
php artisan tail production --path=/var/www/omapi/app/storage/logs/fpm-fcgi-2014-12-12.log --env=local
就可以实时查看 Log 输出了:
php artisan help tail
以上就是本文的全部内容,希望对大家的学习有所帮助,更多相关内容请关注PHP中文网!
相关推荐:
The above is the detailed content of How to view logs in laravel terminal. For more information, please follow other related articles on the PHP Chinese website!