Download the PHP package caixingyue/laravel-star-log without Composer
On this page you can find all versions of the php package caixingyue/laravel-star-log. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download caixingyue/laravel-star-log
More information about caixingyue/laravel-star-log
Files in caixingyue/laravel-star-log
Package laravel-star-log
Short Description This is a package that enhances the Laravel log format. It can inject request ID, craftsman ID, queue ID, and supports enhanced capabilities such as routing request log, HTTP client request log, SQL Query log, etc.
License MIT
Informations about the package laravel-star-log
Rebuild the log structure based on laravel log
This is a package that enhances the Laravel log format. It can inject request ID, craftsman ID, queue ID, and supports enhanced capabilities such as routing request log, HTTP client request log, SQL Query log, etc.
Installation
You can install the package via composer:
You can publish the config file with:
Usage
Log format configuration
After the installation is complete, you need to add a new information to the configuration file. The following is a common reference example, you can modify the configuration as needed.
Injecting request ID
If you wish to inject the , you may append it to the global stack in your application's file:
Enable request logging
If you would like clients to automatically log request and response information when they request your routes, you may attach this to the global stack in your application's file:
Routing Configuration
Sometimes we want to return the request ID in the response header when responding to troubleshoot problems. Or we may not want to record request logs for certain URLs or methods, or even secret field information. For these situations, you can add relevant configuration to the configuration file:
When you want to return the request ID in the response, you can set to in the configuration.
If you do not want to record request logs for certain URLs, you can add the information to be excluded in the .
- For example, you can add to exclude the path from processing.
- You can use the * wildcard to match all paths in a pattern. For example, will exclude all paths starting with .
- If desired, you can also add the full URL including domain name and protocol.
- If you want to exclude certain paths based on the URL's query string, include those as well. For example, .
If you do not want to record requests of certain methods, such as , , etc., you can add the information to be excluded in .
For some secret information fields that you do not want to be recorded in the log, you can add the relevant field name in the field, and the system will automatically replace the data with before recording the data. Currently, we have configured the common fields , , and as secret fields, which can be adjusted if necessary.
Injecting Artisan ID
If you wish to inject the , you may use the method in your command class:
Injecting Queue ID
If you wish to inject the , you may use the method in your job class:
Generally, only can use the . If also needs to use it, you can call in to initialize it.
Enable HTTP client request logging
If you want the system to automatically log requests and responses when making HTTP client requests, you can set to in the configuration.
For some secret information fields that you do not want to be recorded in the log, you can add the relevant field name in the field, and the system will automatically replace the data with before recording the data. Currently, we have configured the common fields , , and as secret fields, which can be adjusted if necessary.
Enable SQL Query logging
If you want the system to automatically log when SQL queries are issued, you can set to in the configuration.
If you do not want to record certain SQL queries, you can add the SQL to be excluded in the except
. The SQL statement to be excluded does not have to be complete, as long as it is a part of the SQL.
By default, we will exclude SQL operations on laravel basic tables. If necessary, you can adjust them as needed.
In the exclusion, * key means that it has effect in all class methods. If you need to limit the restrictions within a class, you can specify the class name as the key, such as .
Helpers
We provide some helpers that can help you get some data in different scenarios.
Generally, in classes that use injected id, we recommend using the $this method.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-star-log with dependencies
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^10.0||^11.0
mobiledetect/mobiledetectlib Version ^4.8