Log collection – Laravel & Phplogger

Error collection with Phplogger is fairly easy, you would need to install Phplogger client from the official page and a working Phplogger token, which can be found on the Product setup page.

In case you don’t have your development environment set up, here is a nice tutorial on the basic PHP project configuration with Docker – https://blog.phplogger.com/2019/07/11/creating-a-php-project-with-docker/


To install the Phplogger client you would need Composer dependency management. Go to your project folder and run the composer require command in the terminal.

composer require phplogger/phplogger

Next we need to locate the logging configuration file in your Laravel project. The default location is ./config/logging.php. This file contains the list of available channels for you to use. We need to add another element to the list, which we will call phplogger. Add this element to the channels array and replace b444ac06613fc8d63795be9ad0beaf550 with your token from Product setup page.

        'phplogger' => [
            'driver' => 'monolog',
            'level' => 'debug',
            'handler' => PhpLogger\Monolog\PhpLoggerHandler::class,
            'handler_with' => [
                'token' => 'b444ac06613fc8d63795be9ad0beaf550'

Now we need to use this channel in your project. Open ./.env file and find the line which starts with LOG_CHANNEL. The default line usually is LOG_CHANNEL=stack. We need to change the value to phplogger, like so


Good job! Now everything you log will be available to you at phplogger.com.