Skip to content

Commit fb19aec

Browse files
committed
Update README.md
1 parent de48199 commit fb19aec

1 file changed

Lines changed: 65 additions & 9 deletions

File tree

README.md

Lines changed: 65 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,72 @@ http://www.stackify.com/sign-up/
1313
## Standalone logger
1414
Install the latest version with `composer require stackify/logger`
1515

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+
### <a name="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);
28+
```
29+
```yml
30+
# or configuration file example
31+
services:
32+
stackify_transport:
33+
class: "Stackify\\Log\\Transport\ExecTransport"
34+
arguments: ["api_key"]
35+
stackify_handler:
36+
class: "Stackify\\Log\\Monolog\\Handler"
37+
arguments: ["application_name", "environment_name", "@stackify_transport"]
38+
```
39+
### Configuration
40+
##### Proxy
41+
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);
57+
```
58+
```yml
59+
# or configuration file example
60+
services:
61+
stackify_transport:
62+
class: "Stackify\\Log\\Transport\CurlTransport"
63+
arguments: ["api_key"]
64+
stackify_handler:
65+
class: "Stackify\\Log\\Monolog\\Handler"
66+
arguments: ["application_name", "environment_name", "@stackify_transport"]
67+
```
68+
###Configuration
69+
#### Proxy
70+
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:
1680
```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]);
2682
```
2783

2884
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

Comments
 (0)