laravel在终端中查看日志的方法
来源:互联网 发布:8a商业源码 编辑:程序博客网 时间:2024/06/06 04:49
php artisan tail --path=/Users/henryj/workspace_php/makerlab/app/storage/logs/laravel-2015-04-22.log 在mac book终端中运行的指令
原文网址:https://phphub.org/topics/291
使用 `php artisan tail` 来实时查看 Laravel 应用程序的 Log
说明
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
接下来我们做些配置, 查看生产环境下的 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
0 0
- laravel在终端中查看日志的方法
- linux中查看日志的方法介绍
- 请问在终端中怎么查看上一屏的信息呢
- 如何在laravel中使用post方法的ajax请求
- Linux中在终端打开图形界面的文件夹的方法
- Laravel 在构造方法中使用session
- 在laravel框架中如何查看自己写的sql原生格式
- 在eclipse中查看手机安装apk的日志
- 09 在ubuntu中切换多终端的方法
- Ubuntu在终端中安装和卸载软件的方法
- 在centos中键入不同终端的几种方法
- 在Linux命令行终端中使用python的简单方法
- 安卓开发中实用的查看日志方法
- 安卓开发中实用的查看日志方法
- Grep查看日志的方法
- 查看poi日志的方法
- 在 Laravel 中使用 Laravel Searchy 遇到的坑
- laravel 的日志
- mysql按照网段分类IP
- WebAPP设计和入门开发需要注意的5个事项
- Appium基于安卓的各种FindElement的控件定位方法实践和建议
- JAVA操作properties文件
- Linux学习笔记(五)
- laravel在终端中查看日志的方法
- poj 2537 Tight words 概率dp
- MFC中获取App,MainFrame,Doc和View类等指针的方法
- 日期转换格式
- JSSE系统属性的配置
- listview一个需要注意的地方(想不到叫什么标题了)
- android 超轻量级数据存储类
- Android SDK镜像
- ImageSpan的使用