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 里面加上

  1. Event::listen('illuminate.query', function($query, $bindings, $time, $name)
  2. {
  3. $data = compact('bindings', 'time', 'name');
  4.  
  5. // Format binding data for sql insertion
  6. foreach ($bindings as $i => $binding)
  7. {
  8. if ($binding instanceof \DateTime)
  9. {
  10. $bindings[$i] = $binding->format('\'Y-m-d H:i:s\'');
  11. }
  12. else if (is_string($binding))
  13. {
  14. $bindings[$i] = "'$binding'";
  15. }
  16. }
  17.  
  18. // Insert bindings into query
  19. $query = str_replace(array('%', '?'), array('%%', '%s'), $query);
  20. $query = vsprintf($query, $bindings);
  21.  
  22. Log::info($query, $data);
  23. });

生产环境下的 Log

接下来我们做些配置, 查看生产环境下的 Log .

修改app/config/remote.php 文件

  1. 'connections' => array(
  2. 'production' => array(
  3. 'host' => '117.111.111.111', //
  4. 'username' => 'root',
  5. 'password' => '',
  6. 'key' => '/Users/username/.ssh/id_rsa',
  7. 'keyphrase' => '',
  8. 'root' => '/var/webroot',
  9. ),
  10. ),

服务器验证可以选择 用户名密码 方式, 也可以设置 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

laravel在终端中查看日志的方法的更多相关文章

  1. 在Linux终端中查看公有IP的方法详解

    首先回顾一下一般的查看IP的命令: ifconfigLinux查看IP地址的命令--ifconfigifconfig命令用于查看和更改网络接口的地址和参数 $ifconfig -a  lo0: fla ...

  2. linux查看日志的方法

    linux查看日志文件内容命令tail.cat.tac.head.echo tail -f test.log你会看到屏幕不断有内容被打印出来. 这时候中断第一个进程Ctrl-C, ---------- ...

  3. Mac系统在终端中查看CPU信息的命令

    在mac os x的终端中以命令行的形式查看本机cpu信息: sysctl -n machdep.cpu.brand_string E.G. lis-mbp:Home jenkins$ sysctl ...

  4. Linux中查看日志文件的正确姿势,求你别tail走天下了!

    作为一个后端开发工程师,在Linux中查看查看文件内容是基本操作了.尤其是通常要分析日志文件排查问题,那么我们应该如何正确打开日志文件呢?对于笔者这种小菜鸡来说,第一反应就是 cat,tail,vi( ...

  5. VLC查看日志的方法

    最近使用VLC去播放rtsp网络串流总是失败,显示要查看日志,查看的方法: 进入VLC的GUI,点击视图,添加界面,添加调试窗口: 添加调试窗口,会弹出界面: 上面会有报错的提示. 大佬如果有其他的办 ...

  6. linux几种查看日志的方法

    linux tail命令用途是依照要求将指定的文件的最后部分输出到标准设备,通常是终端,通俗讲来,就是把某个档案文件的最后几行显示到终端上,假设该档案有更新,tail会自己主动刷新,确保你看到最新的档 ...

  7. 在Android Studio中查看Sqlite的方法

    只说最好的方法,使用工具stetho:http://facebook.github.io/stetho/ 1.在Gragle中加上如下语句: dependencies { // Stetho core ...

  8. linux系统中查看日志及系统信息

    cat tail -f 日 志 文 件说 明 /var/log/message系统启动后的信息和错误日志,是Red Hat Linux中最常用的日志之一 /var/log/secure与安全相关的日志 ...

  9. Grep查看日志的方法【转】

    转自:http://blog.csdn.net/stormkey/article/details/5905204 版权声明 :转载时请以超链接形式标明文章原始出处和作者信息及本声明 http://go ...

随机推荐

  1. 洛谷 P2356 弹珠游戏

    题目链接:https://www.luogu.org/problemnew/show/P2356 题目 题目描述 MedalPluS 和他的小伙伴 NOIRP 发掘了一个骨灰级别的游戏——超级弹珠. ...

  2. 手把手教你如何玩转消息中间件(ActiveMQ) https://blog.csdn.net/cs_hnu_scw/article/details/81040834

    #情景引入小白:起床起床起床起床....快起床~我:怎么了又,大惊小怪,吓到我了.小白:我有事有事想找你,十万火急呢~~我:你能有什么事?反正我不信..那你说说看~~小白:就是我有两个小表弟,叫大白和 ...

  3. css 垂直+水平居中

    垂直+水平居中是一个老生常谈的问题了,现在就固定高度和不固定高度两种情况去讨论 1.父盒子固定高度[定位] 实现1: father-box: position:relative child-box:p ...

  4. Permutations 全排列 回溯

    Given a collection of numbers, return all possible permutations. For example,[1,2,3] have the follow ...

  5. 【JZOJ3213】【SDOI2013】直径

    ╰( ̄▽ ̄)╭ 小 Q最近学习了一些图论知识.根据课本,有如下定义. 树:无回路且连通的无向图,每条边都有正整数的权值来表示其长度.如果一棵树有N个节点,可以证明其有且仅有 N-1 条边. 路径:一棵 ...

  6. js获取url制定的某个参数

    <script>function getURLParam(strParamName, url) {    var strReturn = "";    var strH ...

  7. 2018-2-13-win10-uwp-获取按钮鼠标左键按下

    title author date CreateTime categories win10 uwp 获取按钮鼠标左键按下 lindexi 2018-2-13 17:23:3 +0800 2018-2- ...

  8. python 文件读写编码

  9. Libevent:11使用Libevent的DNS上层和底层功能

    Libevent提供了一些API用来进行DNS域名解析,并且提供了实现简单DNS服务器的能力. 本章首先描述域名解析的上层功能,然后介绍底层功能及服务器功能. 注意:Libevent的当前DNS客户端 ...

  10. jquery 即点即改

    //在html中建立表单. <table border=""> <th>编号</th> <th>用户名</th> < ...