webman2.1版本 webman/log 无法记录SQL日志

皮皮侠

问题描述

webman2.1版本 webman/log 无法记录SQL日志

印象中2.1之前的版本是可以记录SQL日志,最近第一次使用2.1版本无论如何都没日志记录,之前使用的ORM是think-orm

日志截图:
截图

composer.json

{
  "name": "workerman/webman",
  "type": "project",
  "keywords": [
    "high performance",
    "http service"
  ],
  "homepage": "https://www.workerman.net",
  "license": "MIT",
  "description": "High performance HTTP Service Framework.",
  "authors": [
    {
      "name": "walkor",
      "email": "walkor@workerman.net",
      "homepage": "https://www.workerman.net",
      "role": "Developer"
    }
  ],
  "support": {
    "email": "walkor@workerman.net",
    "issues": "https://github.com/walkor/webman/issues",
    "forum": "https://wenda.workerman.net/",
    "wiki": "https://workerman.net/doc/webman",
    "source": "https://github.com/walkor/webman"
  },
  "require": {
    "php": ">=8.1",
    "workerman/webman-framework": "^2.1",
    "monolog/monolog": "^2.0",
    "webman/database": "^2.1",
    "webman/log": "^2.1",
    "guzzlehttp/guzzle": "^7.9"
  },
  "suggest": {
    "ext-event": "For better performance. "
  },
  "autoload": {
    "psr-4": {
      "": "./",
      "app\\": "./app",
      "App\\": "./app",
      "app\\View\\Components\\": "./app/view/components"
    }
  },
  "scripts": {
    "post-package-install": [
      "support\\Plugin::install"
    ],
    "post-package-update": [
      "support\\Plugin::install"
    ],
    "pre-package-uninstall": [
      "support\\Plugin::uninstall"
    ]
  },
  "minimum-stability": "dev",
  "prefer-stable": true
}

composer info

brick/math                      0.12.1    Arbitrary-precision arithmetic library
carbonphp/carbon-doctrine-types 2.1.0     Types to use Carbon in Doctrine
doctrine/inflector              2.0.10    PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural form...
guzzlehttp/guzzle               7.9.2     Guzzle is a PHP HTTP client library
guzzlehttp/promises             2.0.4     Guzzle promises library
guzzlehttp/psr7                 2.7.0     PSR-7 message implementation that also provides common utility methods
illuminate/collections          v10.48.28 The Illuminate Collections package.
illuminate/conditionable        v10.48.28 The Illuminate Conditionable package.
illuminate/container            v10.48.28 The Illuminate Container package.
illuminate/contracts            v10.48.28 The Illuminate Contracts package.
illuminate/database             v10.48.28 The Illuminate Database package.
illuminate/macroable            v10.48.28 The Illuminate Macroable package.
illuminate/support              v10.48.28 The Illuminate Support package.
laravel/serializable-closure    v2.0.3    Laravel Serializable Closure provides an easy and secure way to serialize closures in PHP.
monolog/monolog                 2.10.0    Sends your logs to files, sockets, inboxes, databases and various web services
nesbot/carbon                   2.73.0    An API extension for DateTime that supports 281 different languages.
nikic/fast-route                v1.3.0    Fast request router for PHP
psr/clock                       1.0.0     Common interface for reading the clock.
psr/container                   2.0.2     Common Container Interface (PHP FIG PSR-11)
psr/http-client                 1.0.3     Common interface for HTTP clients
psr/http-factory                1.1.0     PSR-17: Common interfaces for PSR-7 HTTP message factories
psr/http-message                2.0       Common interface for HTTP messages
psr/log                         3.0.2     Common interface for logging libraries
psr/simple-cache                3.0.0     Common interfaces for simple caching
ralouphie/getallheaders         3.0.3     A polyfill for getallheaders.
symfony/deprecation-contracts   v3.5.1    A generic function and convention to trigger deprecation notices
symfony/polyfill-mbstring       v1.31.0   Symfony polyfill for the Mbstring extension
symfony/polyfill-php80          v1.31.0   Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions
symfony/translation             v6.4.13   Provides tools to internationalize your application
symfony/translation-contracts   v3.5.1    Generic abstractions related to translation
voku/portable-ascii             2.0.3     Portable ASCII library - performance optimized (ascii) string functions for php.
webman/database                 v2.1.2    Webman database
webman/log                      v2.1.2    Webman plugin webman/log
workerman/coroutine             v1.1.1    Workerman coroutine
workerman/webman-framework      v2.1.1    High performance HTTP Service Framework.
workerman/workerman             v5.1.0    An asynchronous event driven PHP framework for easily building fast, scalable network applications.

/config/log.php

<?php

return [
    'default' => [
        'handlers' => [
            [
                'class' => Monolog\Handler\RotatingFileHandler::class,
                'constructor' => [
                    runtime_path() . '/logs/webman.log',
                    7, //$maxFiles
                    Monolog\Logger::DEBUG,
                ],
                'formatter' => [
                    'class' => Monolog\Formatter\LineFormatter::class,
                    'constructor' => [null, 'Y-m-d H:i:s', true],
                ],
            ],
            [
                'class' => \Monolog\Handler\StreamHandler::class,
                'constructor' => [
                    STDOUT,
                ],
                'formatter' => [
                    'class' => Monolog\Formatter\LineFormatter::class,
                    'constructor' => [null, 'Y-m-d H:i:s.u', true],
                ],
            ]
        ],
    ],
];

为此你搜索到了哪些方案及不适用的原因

通过本人简单查看webman/log中 Webman\Log\Middleware.php文件 发现第105行的的日志判断条件没成立,由于本人水平有限 就没再继续了
截图

补充:

我换think-orm能记录SQL日志
截图

243 2 0
2个回答

composer info里没看到 think-orm

  • 皮皮侠 6天前

    我用的"webman/database": "^2.1", 这个包不是用的illuminate/database吗?难道只能think-orm才能记录SQL日志吗

  • walkor 6天前

    好吧,我看你说明里和截图里都是说的 think-orm。
    发下完整的测试代码

  • 皮皮侠 6天前

    我换了think-orm 能记录日志了 代码稍等我整了一下

想起来了,你没装 illuminate/events

×
🔝