bytetcore/lalog 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

bytetcore/lalog

Composer 安装命令:

composer require bytetcore/lalog

包简介

A robust Laravel SQL Query Logger that logs all database queries to files with rotation, performance metrics, and cross-database compatibility.

README 文档

README

Latest Version License Latest Stable Version Total Downloads Latest Unstable Version

Automatically log all SQL queries to files with binding interpolation, time tracking, and file rotation support. Perfect for debugging and performance analysis during development.

Features

  • 🔍 Full SQL Logging — Captures every query with bindings interpolated
  • ⏱️ Query Time — Records execution time for each query
  • 📁 File Rotation — Automatically creates new files when size limit is reached
  • 🗑️ Auto Clear — Optionally clears previous logs each request cycle
  • ⚙️ Configurable — Disk, directory, format, max size, extension — all customizable
  • 🚀 Zero Config — Works out of the box with sensible defaults

Requirements

  • PHP 8.0+
  • Laravel 9.x+

Installation

composer require bytetcore/lalog --dev

The package auto-discovers its ServiceProvider. No manual registration needed.

Publish Config (Optional)

php artisan vendor:publish --tag=lalog-config

Configuration

Add to your .env:

APP_LOG_QUERY=true

Available Options

Option Env Variable Default Description
enabled APP_LOG_QUERY false Enable/disable query logging
disk LALOG_DISK local Storage disk (any disk from filesystems.php)
directory LALOG_DIRECTORY query Directory within the disk
max_size LALOG_MAX_SIZE 2000000 Max file size in bytes (~2MB)
format LALOG_FORMAT sql-{date} File name format ({date} placeholder)
date_format LALOG_DATE_FORMAT Y-m-d PHP date format for {date}
extension LALOG_EXTENSION sql File extension
clear_on_start LALOG_CLEAR_ON_START true Delete current day's log on start

Example Config

// config/lalog.php
return [
    'enabled'        => env('APP_LOG_QUERY', false),
    'disk'           => env('LALOG_DISK', 'local'),
    'directory'      => env('LALOG_DIRECTORY', 'query'),
    'max_size'       => env('LALOG_MAX_SIZE', 2000000),
    'format'         => env('LALOG_FORMAT', 'sql-{date}'),
    'date_format'    => env('LALOG_DATE_FORMAT', 'Y-m-d'),
    'extension'      => env('LALOG_EXTENSION', 'sql'),
    'clear_on_start' => env('LALOG_CLEAR_ON_START', true),
];

Output Example

File: storage/app/query/sql-2026-04-03.sql

----------START---------
Date: 2026-04-03 13:45:12
Time query: 2.34(ms)
select * from `users` where `email` = 'john@example.com' limit 1;
----------END----------

Date: 2026-04-03 13:45:12
Time query: 0.89(ms)
select * from `posts` where `user_id` = '1' order by `created_at` desc;
----------END----------

File Rotation

When a log file exceeds max_size, new files are created with an incremented index:

query/sql-2026-04-03.sql      (2MB reached)
query/sql-2026-04-03-1.sql    (next file)
query/sql-2026-04-03-2.sql    (and so on)

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

See AUTHORS for the list of contributors.

License

Licensed under the Apache License 2.0. Please see License File for more information.

bytetcore/lalog 适用场景与选型建议

bytetcore/lalog 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 2, 最近一次更新时间为 2026 年 04 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「log」 「logging」 「database」 「performance」 「sql」 「debug」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 bytetcore/lalog 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 bytetcore/lalog 我们能提供哪些服务?
定制开发 / 二次开发

基于 bytetcore/lalog 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2026-04-03