定制 lingxi/laravel-sql-logger 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lingxi/laravel-sql-logger

Composer 安装命令:

composer require lingxi/laravel-sql-logger

包简介

A tool to log all queries for laravel/lumen application.

README 文档

README

📝 This package allows you to log SQL queries (and slow SQL queries) to log file in Laravel/Lumen framework. Inspiration form mnabialek/laravel-sql-logger

Installation

composer require lingxi/laravel-sql-logger --dev

Please keep the --dev option. (it's recommended to use this package only for development). The Logger will be enabled when APP_DEBUG is true

Configuration

If you use Laravel < 5.5 open app/Providers/AppServiceProvider.php and in register method add:

public function register()
{
    if ($this->app['config']->get('app.debug')) {
        $this->app->register(\Lingxi\LaravelSqlLogger\Providers\ServiceProvider::class);
    }
}

Laravel 5.5 uses Package Auto-Discovery and it will automatically load this service provider so you don't need to add anything into above file.

If you are using Lumen open bootstrap/app.php and add:

if (env('APP_DEBUG')) {
    $app->register(\Lingxi\LaravelSqlLogger\Providers\LumenServiceProvider::class);
}

If you use Laravel < 5.5 run:

php artisan vendor:publish --provider="Lingxi\LaravelSqlLogger\Providers\ServiceProvider"

in your console to publish default configuration files.

If you are using Laravel 5.5 run:

php artisan vendor:publish

and choose the number matching "Lingxi\LaravelSqlLogger\Providers\ServiceProvider" provider. This operation will create config file in config/sql_loger.php. By default you should not edit published file because all the settings are loaded from .env file by default.

For Lumen you should skip this step.

In your .env file add the following entries:

# Whether all SQL queries should be logged
SQL_LOG_QUERIES=true 

# Whether slow SQL queries should be logged (you can log all queries and
# also slow queries in separate file or you might to want log only slow queries)
SQL_LOG_SLOW_QUERIES=true

# Time of query (in milliseconds) when this query is considered as slow
SQL_SLOW_QUERIES_MIN_EXEC_TIME=100

#Whether slow SQL queries should be logged (you can log all queries and
#also slow queries in separate file or you might to want log only slow queries)
SQL_LOG_OVERRIDE=false

# Directory where log files will be saved
SQL_LOG_DIRECTORY=logs/sql

# Whether execution time in log file should be displayed in seconds(by default it's in milliseconds)
SQL_CONVERT_TIME_TO_SECONDS=false

# Whether artisan queries should be logged to separate files
SQL_LOG_SEPARATE_ARTISAN=false

License

MIT

统计信息

  • 总下载量: 1.73k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 5
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固