Download the PHP package kitloong/laravel-app-logger without Composer
On this page you can find all versions of the php package kitloong/laravel-app-logger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kitloong/laravel-app-logger
More information about kitloong/laravel-app-logger
Files in kitloong/laravel-app-logger
Package laravel-app-logger
Short Description Laravel log for your application
License MIT
Homepage https://github.com/kitloong/laravel-app-logger
Informations about the package laravel-app-logger
Laravel Application Logger
This package provides middleware that generates HTTP request and performance logs from incoming requests.
This package also provides a Database query log to log all executed queries in your application.
Installation
Usage
To start using HTTP request and performance logger please add the package's middleware in your app/Http/Kernel.php
or routes.
No code modification needed to use the Database query log, you only need to enable it through .env
.
By default, HTTP request and performance are enabled while the query log is disabled.
However, you could change each setting respectively to a different environment.
Log format
Http request log
Performance log
Query log
What's more
This package uses https://github.com/spatie/laravel-http-logger as the base for the HTTP request log, as well as the code design pattern.
It is common to receive tons of incoming requests in a real-life production application.
To ease for analysis, a unique string is embedded into HTTP request and performance log to indicate both log entries are related.
If you found any high memory usage or slow requests you could easily grep request log by the unique string for more information.
Configuration
You could also publish the config file to change more configuration or even use your own implementation:
You could check the content of the config file here.
Config: Logging channel
By default, Laravel App Logger writes logs into your default logging channel.
However, you may implement a new logging channel in Laravel config/logging.php
, and overwrite the channel
in the published config file.
An example is written for a better explanation.
In Laravel config/logging.php
:
In config/app-logger.php
:
Config: Implement own logger
You could even write your own logger implementation and overwrite it in the config file.
Here is the code snippet of HTTP request:
You could find a similar configuration in the performance
and query
section.
When you write your own log_profile
, you must implement each loggers' own LogProfile
interface.
Logger | Interface |
---|---|
http | \KitLoong\AppLogger\HttpLog\HttpLogProfile |
performance | \KitLoong\AppLogger\PerformanceLog\PerformanceLogProfile |
query | \KitLoong\AppLogger\QueryLog\QueryLogProfile |
The interface requires shouldLog
implementation. This is where you place your log condition.
When you write your own log_writer
, you must implement each loggers' own LogWriter
interface.
Logger | Interface |
---|---|
http | \KitLoong\AppLogger\HttpLog\HttpLogWriter |
performance | \KitLoong\AppLogger\PerformanceLog\PerformanceLogWriter |
query | \KitLoong\AppLogger\QueryLog\QueryLogWriter |
The interface requires log
implementation. This is where you define your log body message.
License
The Laravel Application Logger is open-sourced software licensed under the MIT license
All versions of laravel-app-logger with dependencies
illuminate/support Version ^5.8|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
spatie/laravel-http-logger Version ^1.0
ext-json Version *