Download the PHP package pensoft/awt-laravel-log without Composer
On this page you can find all versions of the php package pensoft/awt-laravel-log. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pensoft/awt-laravel-log
More information about pensoft/awt-laravel-log
Files in pensoft/awt-laravel-log
Package awt-laravel-log
Short Description AWT Laravel Log is a small library that sent to Elasticsearch.
License MIT
Informations about the package awt-laravel-log
pensoft/awt-laravel-log
pensoft/awt-laravel-log
is a Composer package designed to integrate Elasticsearch logging into your Laravel application seamlessly. It provides a custom log service for exception handling, allowing you to log exception events into Elasticsearch for enhanced observability.
Installation
You can install the package using Composer:
Usage Instructions
After installing the package, you need to register the logging service with Laravel's exception reporting pipeline. This is done by modifying the reportable()
method within your App\Exceptions\Handler
class.
1. Modify the Handler.php
file
You will integrate the logging service by adding the following code inside the reportable()
method:
Explanation of the Code
class_exists(\Pensoft\AwtLaravelLog\LogElasticsearchService::class)
: Checks if the Elasticsearch logging service class exists before invoking it.app(\Pensoft\AwtLaravelLog\LogElasticsearchService::class)($e)
: Resolves the service from the Laravel service container and calls it with the exception$e
. This logs the exception to Elasticsearch.
Configuration
The logging service will automatically integrate into your application's exception reporting pipeline. If you require custom Elasticsearch configurations (host, index, or other settings), you may extend the LogElasticsearchService
or override settings in your Laravel application's service provider.
Requirements
- Laravel 8.x or higher
- PHP 8.x or higher
- Elasticsearch server (if connecting directly to a server endpoint)
Environment Variables to Configure
To make this configuration functional, you should define the necessary environment variables in your .env
file. Below are the environment variables that must be configured: