dongnianwo8289 2016-04-21 11:46
浏览 72

为每个事件管理laravel 5日志的最佳方式

I wants to logs for each events happened in my website. I would like to know what will be the best way to handle this?

I looked at the packages available but it's not in my requirement.

Let say I wants to record every email activity went through the system plus all insert/update/delete performed by the system user.

I saw EventListener but each time I have to fire an event from the controller I would love if is there any way if I just have to write one time code at somewhere so anytime insert/update/delete happened It will be recorded yes plus emails as well.

Help would be most appreciated.

Thank you.

  • 写回答

1条回答 默认 最新

  • dsxxqndv41105 2016-04-21 11:51
    关注

    /Providers/AppServiceProvider.php

    use Log;
    
    public function boot()
    {
        DB::listen(function ($event) {
            Log::info('Running SQL query: '.$event->sql);
        });
        //...
    }
    

    That will push an info entry on every query that's executed on the website. Have a look at the docs for specific information on the Log levels.

    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100