- 1 Minute to read
- Print
- DarkLight
- PDF
Stackify PHP Logger
- 1 Minute to read
- Print
- DarkLight
- PDF
Guide on setting up Stackify's Standalone PHP Logger to track application logs and errors.
Installation with Linux Agent
This is the suggested installation option, offering the best logging performance.
Install Stackify Linux Agent
Install stackify/logger module into your project:
composer require stackify/logger
Configure stackify/logger module
Replace Application Name and Environment Name with appropriate values.
use Stackify\Log\Standalone\Logger;
$logger = new Logger('Application Name', 'Environment Name');
Installation without Linux Agent
This option does not require a Stackify Linux Agent to be installed because it sends data directly to Stackify services. It collects log entries in batches, calls curl using the exec function, and sends data to the background immediately [exec('curl ... &')]
. This will affect the performance of your application minimally, but it requires permissions to call exec inside the PHP script and it may cause silent data loss in the event of any network issues.
Install stackify/logger module into your project:
composer require stackify/logger
Configure stackify/logger module
Replace Stackify API Key, Application Name and Environment Name with appropriate values.
use Stackify\Log\Transport\ExecTransport;
use Stackify\Log\Standalone\Logger;
$transport = new ExecTransport('Stackify API Key');
$logger = new Logger('Application Name', 'Environment Name', $transport);
Optional Settings
Proxy:
ExecTransport supports data delivery through proxy. Specify proxy using libcurl format: <[protocol://][user:password@]proxyhost[:port]>
:
$transport = new ExecTransport($apiKey, ['proxy' => 'https://55.88.22.11:3128']);
Curl path:
It can be useful to specify curl
destination path for ExecTransport. This option is set to 'curl' by default.
$transport = new ExecTransport($apiKey, ['curlPath' => '/usr/bin/curl']);
Server environment variables can be added to error log message metadata.
$logger = new Logger('Application Name', 'Environment Name', $transport, true);