Download the PHP package zdz/laravel-middleware-log without Composer

On this page you can find all versions of the php package zdz/laravel-middleware-log. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-middleware-log

laravel-middleware-log

laravel日志中间件

Requirements

Installation

Usage

注册中间件(选择合适的)

app/Http/Kernel.php 中的 $middleware 属性中列出这个中间件

监听sql语句

Log结构

默认请求一次,记录一条日志,日志为json字符串,结构如下:

字段 描述
message 默认为auto-log,修改config里的log_message自定义
level laravel日志级别
level_name laravel日志级别名称
channel
datetime 记录时间
extra
context 日志内容,修改config里的log_fields自定义默认记录字段
|- exec_exception 程序运行抛出的异常(内置,不可修改)
|- exec_ms 执行时间,依赖于常量LARAVEL_START, 没有则可以在public/index.php添加 define('LARAVEL_START', microtime(true));(内置,不可修改)
|- time 内置记录时间,格式:Y-m-d H:i:s
|- full_url 完整路由
|- path_info 请求路由
|- client_ip 客户端ip
|- request_method 请求方法
|- request_header 请求header
|- request_params 请求参数
|- response_header 响应header
|- response_body 响应结果
|- db_sql sql语句数组(需监听sql语句)
|-- connection_name 连接名称
|-- sql sql语句
|-- bindings 绑定参数
|-- ms sql执行时间

Configuration(可选,自定义配置)

使用以下命令发布配置,发布之后会生成config/log-middleware.php,在此文件里修改配置

config/log-middleware.php

字段 类型 描述 示例
exclude_route array 忽略的路由,在此数组中则不会记录日志,支持通配符* ['api/log/test', 'web/*']
exclude_route_fields array 忽略的路由字段,记录路由日志,但不记录字段里的值,支持通配符* ['api/log/*' => [ 'response_body' ] ]
exclude_exception array 忽略的异常类,如果是此异常则不记录到exec_exception 默认忽略 [Illuminate\Validation\ValidationException::class,]
exclude_exception_fields array 用于抛出异常时,字段内容置为空 默认: [ 'response_body' ]
log_fields array 记录的数据,可自定义,形式:
key => [ 类(request、response), 方法, 属性 ]
有以下三种情况:
1. 'full_url' => [ 'request', 'fullUrl' ] = $request->fullUrl()
2. 'response_header' => [ 'response', 'all', 'headers' ] = $response->headers->all()
3. 'response_header' => [ 'response', '', 'headers' ] = $response->headers
log_message string 日志消息 默认:auto-log
log_level string 日志级别: debug, info, notice, warning, error, critical, alert, emergency 默认:debug
handler string 默认:修改此handler自定义自己的方法 zdz\LaravelMiddlewareLog\handle\SingleHandler::class

其他操作

使用zdz\LaravelMiddlewareLog\tool\FormatLog增加日志的内容

提供的方法

write(string $point, string $op, $context = '', bool $jsonStrToArray = true): void
writeMany(array $array): void

All versions of laravel-middleware-log with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2
ext-json Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package zdz/laravel-middleware-log contains the following files

Loading the files please wait ....