You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Install the latest version with `composer require stackify/logger`
15
15
16
+
There are three different transport options that can be configured to send data to Stackify. Below will show how to implement the different transport options:
17
+
18
+
### <aname="transport"></a>Transport options:
19
+
20
+
21
+
- <b>ExecTransport</b> does not require Stackify agent to be installed because it sends data directly to Stackify services. It collects log entries in a single batch, calls curl using the ```exec``` function, and sends it 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. This transport method does not work on Windows. To configure ExecTransport you need to pass the environment name and API key (license key):
22
+
```php
23
+
use Stackify\Log\Transport\ExecTransport;
24
+
use Stackify\Log\Monolog\Handler as StackifyHandler;
25
+
26
+
$transport = new ExecTransport('api_key');
27
+
$handler = new StackifyHandler('application_name', 'environment_name', $transport);
ExecTransport and CurlTransport support data delivery through proxy. Specify proxy using [libcurl format](http://curl.haxx.se/libcurl/c/CURLOPT_PROXY.html): <[protocol://][user:password@]proxyhost[:port]>
42
+
```php
43
+
$transport = new ExecTransport($apiKey, ['proxy' => 'https://55.88.22.11:3128']);
44
+
```
45
+
##### Curl path
46
+
It can be useful to specify ```curl``` destination path for ExecTransport. This option is set to 'curl' by default.
47
+
```php
48
+
$transport = new ExecTransport($apiKey, ['curlPath' => '/usr/bin/curl']);
49
+
```
50
+
- <b>CurlTransport</b> does not require a Stackify agent to be installed and it also sends data directly to Stackify services. It collects log entries in a single batch and sends data using native [PHP cURL](http://php.net/manual/en/book.curl.php) functions. This way is a blocking one, so it should not be used on production environments. To configure CurlTransport you need to pass environment name and API key (license key):
51
+
```php
52
+
use Stackify\Log\Transport\CurlTransport;
53
+
use Stackify\Log\Monolog\Handler as StackifyHandler;
54
+
55
+
$transport = new CurlTransport('api_key');
56
+
$handler = new StackifyHandler('application_name', 'environment_name', $transport);
ExecTransport and CurlTransport support data delivery through proxy. Specify proxy using [libcurl format](http://curl.haxx.se/libcurl/c/CURLOPT_PROXY.html): <[protocol://][user:password@]proxyhost[:port]>
71
+
```php
72
+
$transport = new CurlTransport($apiKey, ['proxy' => 'https://55.88.22.11:3128']);
73
+
```
74
+
75
+
- <b>AgentTransport</b> does not require additional configuration on PHP side because all data is passed to the [Stackify agent](https://stackify.screenstepslive.com/s/3095/m/7787/l/119709-installation-for-linux), which must be installed on the same machine. Local TCP socket is used, so performance of your application is affected minimally.
76
+
77
+
## Troubleshooting
78
+
If transport does not work, try looking into ```vendor\stackify\logger\src\Stackify\debug\log.log``` file (if it is available for writing). Errors are also written to global PHP [error_log](http://php.net/manual/en/errorfunc.configuration.php#ini.error-log).
79
+
Note that ExecTransport does not produce any errors at all, but you can switch it to debug mode:
16
80
```php
17
-
use Stackify\Log\Standalone\Logger;
18
-
19
-
$logger = new Logger('appname.com');
20
-
$logger->warning('something happened');
21
-
try {
22
-
$db->connect();
23
-
catch (DbException $ex) {
24
-
$logger->error('DB is not available', ['ex' => $ex]);
25
-
}
81
+
$transport = new ExecTransport($apiKey, ['debug' => true]);
26
82
```
27
83
28
84
By default handler requires [Stackify agent](https://stackify.screenstepslive.com/s/3095/m/7787/l/119709-installation-for-linux) to be running.
0 commit comments