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.
Go to your project directory and install latest version of the library using following command
sudo php composer.phar require monolog/monolog
Install PHP Curl library, if it is not already installed using following command.
sudo apt-get install curl libcurl3 libcurl3-dev php5-curl
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');
- TOKEN: your customer token from the source setup page
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 Syslog – Send PHP logs using Syslog.
- Laravel logs – A wrapper to Monolog library to send logs to Loggly.
- Loggly Libraries Catalog – The libraries available for sending PHP logs to Loggly.
- 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.
When the APM Integrated Experience is enabled, Loggly shares a common navigation and enhanced feature set with the other integrated experiences' products. How you navigate the product and access its features may vary from these instructions. For more information, go to the APM Integrated Experience documentation.
The scripts are not supported under any SolarWinds support program or service. The scripts are provided AS IS without warranty of any kind. SolarWinds further disclaims all warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The risk arising out of the use or performance of the scripts and documentation stays with you. In no event shall SolarWinds or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the scripts or documentation.