这篇文章主要介绍了关于laravel在终端中查看日志的方法,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下
php artisan tail --path=/Users/henryj/workspace_php/makerlab/app/storage/logs/laravel-2015-04-22.log 在mac book终端中运行的指令
php
artisan tail 命令可用来查看实时的程序运行 log, 在 debug 模式关闭的情况下 ( 如: 生产环境 ), 尤其有用.
默认情况下 tail 只是针对本地的代码
php artisan tail
开发的时候, 还可以打开 SQL 查询语句的 LOG, 配合 php artisan tail 一起使用, 对 SQL 进行监控和调优.
在 app/filters.php 里面加上
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);
});接下来我们做些配置, 查看生产环境下的 Log .
app/config/remote.php 文件'connections' => array( 'production' => array( 'host' => '117.111.111.111', // 'username' => 'root', 'password' => '', 'key' => '/Users/username/.ssh/id_rsa', 'keyphrase' => '', 'root' => '/var/webroot', ), ),
服务器验证可以选择 用户名密码 方式, 也可以设置 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中文网!
相关推荐:
以上就是laravel在终端中查看日志的方法的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号