Support Logging setup

                      PHP Monolog

                      PHP Monolog

                      You can send PHP logs to Loggly using the Monolog library. We will automatically parse the JSON format allowing you to quickly drill down into issues. You can see the Loggly Monolog PHP error handler library code on GitHub or the Packagist repository.

                      PHP Monolog Setup

                      1. Install Monolog library

                      Go to your project directory and install latest version of the library using following command

                      sudo php composer.phar require monolog/monolog

                      2. Install PHP Curl

                      Install PHP Curl library, if it is not already installed using following command.

                      sudo apt-get install curl libcurl3 libcurl3-dev php5-curl

                      3. Add Configuration and send test events

                      Add configuration to the source file and send some test events

                      require_once __DIR__ . '/vendor/autoload.php';
                      use MonologLogger;
                      use MonologHandlerLogglyHandler;
                      use MonologFormatterLogglyFormatter;
                      $log = new Logger('appName');
                      $log->pushHandler(new LogglyHandler('TOKEN/tag/monolog', Logger::INFO));
                      $log->addWarning('test logs to loggly');


                      4. Verify Events

                      Search Loggly for events with the monolog as tag over the past 20 minutes. It may take a few minutes to index the event. If it doesn’t work, see the troubleshooting section below.


                      Click on one of the logs to show a list of JSON fields (see screenshot below). If you don’t see them, please check that you are using one of our automatically parsed formats.
                      PHP Monolog Example

                      Advanced PHP Monolog Options

                      Troubleshooting PHP Monolog

                      • Wait a few minutes in case indexing needs to catch up
                      • Verify if the Customer token is correct in the configuration
                      • See our HTTP Troubleshooting Guide to verify HTTP events are being sent to Loggly.
                      • Search or post your own PHP Monolog questions, or questions on sending log records or log messages in the community forum.
                      Thanks for the feedback! We'll use it to improve our support documentation.