Laravel Setup


 
Step by step installing

 
loggfy/connect is a Laravel Package. In this setup documentation we will use loggfy as an API end point instead of storing data locally.
 
 composer require loggfy/connect    

 
Add the service provider to your config/app.php file
 
    Loggfy\Connect\LoggfyServiceProvider::class,

 
Publish the configuration file(s). In this step all we need to update glog.php file under config directory. We do not need to run migrations. Since we will save all data in loggfy
 
   php artisan vendor:publish --provider="Loggfy\Connect\LoggyServiceProvider" 

 
Then in your bootstrap/app.php add / update your Monolog configiuration.
 
   $app->configureMonologUsing(function ($monolog) {
        $monolog->pushHandler(new \Loggfy\Connect\Loggy());
    }); 

 

 
Configuration: config/loggfy.php
This is hearth of Connect. Therefore please, double notice this part of documentation. Here is the sample config file coming with default settings.
 
Do not forget to enter a API key. Here is a sample entry in configuration:
 
 'api_key'   => '',

 
And at last we need to create some channels for logging only targetted messages:
 
 // All channels must be entered before to send the API. 
    'levels' => ['EMERGENCY', 'ALERT', 'CRITICAL', 'ERROR', 'WARNING', 'NOTICE', 'INFO', 'DEBUG'],
    'channels' => ['test-channel'],    

 
Levels are common do not change them unless you wish to modify them. Channels are your targets.
 
 Log::info('user.register', ['message' => 'User Registration Controller', 'id' => 23, 'name' => 'John Doe', 'email' => '[email protected]']);

 
This static function has accept two parameters. First one is your target channels which has been inserted in configurations. Second is an array. You may pass your own data as an array.