ctz198/sqllisten

laravel sql listen

dev-master 2024-07-29 07:10 UTC

This package is auto-updated.

Last update: 2025-03-29 01:09:01 UTC


README

介绍

laravel SQL 监控

输出SQL日志到文件

安装教程

step 1: 拉取代码
cd project
composer config -g repo.sqllisten vcs https://gitee.com/ctz198/sqllisen.git 
composer require --dev ctz198/sqllisten dev-master
git checkout composer.json 
php artisan package:discover

或者

cd project
composer require --dev ctz198/sqllisten dev-master
git checkout composer.json 
php artisan package:discover
step 2: 修改.env
OPEN_LISTEN_SQL=true
SQL_LOG_PATH=/var/www/storage/logs
SLOW_TIME_LIMIT=100
其他
  • 日志查看工具 LogViewer
    • 仓库地址 https://github.com/opcodesio/log-viewer
    • 官方文档 https://log-viewer.opcodes.io
    • 正则调试 https://regexr.com/7huvh
    • 日志正则样例
        /^{"level":"(?<level>.*)","trace_id":"(?<trace_id>.*)","trace_time":"(?<trace_time>.*)","app_env":"(?<app_env>\S+)","app_name":"(?<app_name>\S+)","req_uri":"(?<req_uri>\S+)","req_method":"(?<req_method>\S+)","req_body":(?<req_body>.*),"sql_exec_time":"(?<sql_exec_time>.*)","sql_uuid":"(?<sql_uuid>.*)","db_connection_name":"(?<db_connection_name>.*)","db_conf":(?<db_conf>.*),"trace_sql":"(?<trace_sql>.*)","trace_sql_bindings":(?<trace_sql_bindings>.*),"execute_sql":"(?<execute_sql>.*)","execute_ms":(?<execute_ms>.*)}/
      
  • docker 安装 LogViewer