{"id":31915466,"url":"https://github.com/stackify/stackify-log-monolog","last_synced_at":"2025-10-13T19:47:28.270Z","repository":{"id":23201868,"uuid":"26558553","full_name":"stackify/stackify-log-monolog","owner":"stackify","description":null,"archived":false,"fork":false,"pushed_at":"2024-05-20T12:30:48.000Z","size":57,"stargazers_count":3,"open_issues_count":0,"forks_count":6,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-09-23T19:37:11.502Z","etag":null,"topics":["monolog","php","stackify"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stackify.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2014-11-12T22:08:55.000Z","updated_at":"2024-05-09T13:51:56.000Z","dependencies_parsed_at":"2024-01-17T09:05:20.117Z","dependency_job_id":null,"html_url":"https://github.com/stackify/stackify-log-monolog","commit_stats":{"total_commits":41,"total_committers":10,"mean_commits":4.1,"dds":0.6585365853658536,"last_synced_commit":"8049948f89714dc29422c686a392e021a2984919"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/stackify/stackify-log-monolog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackify%2Fstackify-log-monolog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackify%2Fstackify-log-monolog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackify%2Fstackify-log-monolog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackify%2Fstackify-log-monolog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stackify","download_url":"https://codeload.github.com/stackify/stackify-log-monolog/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackify%2Fstackify-log-monolog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279016839,"owners_count":26085889,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["monolog","php","stackify"],"created_at":"2025-10-13T19:47:26.684Z","updated_at":"2025-10-13T19:47:28.264Z","avatar_url":"https://github.com/stackify.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Stackify Monolog v3 Handler\n\nMonolog handler for sending log messages and exceptions to Stackify.\nMonolog \u003e= 3.0.0 is supported.\n\nFor Monolog V1\n\n\u003e Use the [1.x branch](https://github.com/stackify/stackify-log-monolog/tree/1.x)\n\nFor Monolog V2\n\n\u003e Use the [2.x branch](https://github.com/stackify/stackify-log-monolog/tree/2.x)\n\n* **Errors and Logs Overview:** http://support.stackify.com/errors-and-logs-overview/\n* **Sign Up for a Trial:** http://www.stackify.com/sign-up/\n\n## Installation\n\nInstall the latest version with `composer require stackify/monolog \"~2.0\"`\n\n### Installation with Linux Agent\n\nThis is the suggested installation option, offering the best logging performance.\n \n**PHP:**\n```php\nuse Monolog\\Logger;\nuse Stackify\\Log\\Monolog\\Handler as StackifyHandler;\n\n$handler = new StackifyHandler('application_name', 'environment_name');\n$logger = new Logger('logger');\n$logger-\u003epushHandler($handler);\n```\n\n**Symfony:**\n```yml\nservices:\n    stackify_handler:\n        class: \"Stackify\\\\Log\\\\Monolog\\\\Handler\"\n        arguments: [\"application_name\", \"environment_name\"]\nmonolog:\n    handlers:\n        stackify:\n            type: service\n            id: stackify_handler\n```\n\n\n#### Optional Settings\n\n**Log Server Environment Variables**\n- Server environment variables can be added to error log message metadata. **Note:** This will log all \nsystem environment variables; do not enable if sensitive information such as passwords or keys are stored this way.\n\n ```php\n$handler = new StackifyHandler('application_name', 'environment_name', null, true); \n```\n\n### Installation without Linux Agent\n\nThis option does not require a Stackify 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 ... \u0026')```]. 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):\n\n**PHP:**\n```php\nuse Stackify\\Log\\Transport\\ExecTransport;\nuse Stackify\\Log\\Monolog\\Handler as StackifyHandler;\n\n$transport = new ExecTransport('api_key');\n$handler = new StackifyHandler('application_name', 'environment_name', $transport);\n$logger = new Logger('logger');\n$logger-\u003epushHandler($handler);\n```\n\n**Symfony:**\n```yml\nservices:\n    stackify_transport:\n        class: \"Stackify\\\\Log\\\\Transport\\ExecTransport\"\n        arguments: [\"api_key\"]\n    stackify_handler:\n        class: \"Stackify\\\\Log\\\\Monolog\\\\Handler\"\n        arguments: [\"application_name\", \"environment_name\", \"@stackify_transport\"]\nmonolog:\n    handlers:\n        stackify:\n            type: service\n            id: stackify_handler\n```\n\n#### Optional Configuration\n\n**Proxy**\n- ExecTransport supports data delivery through proxy. Specify proxy using [libcurl format](http://curl.haxx.se/libcurl/c/CURLOPT_PROXY.html): \u003c[protocol://][user:password@]proxyhost[:port]\u003e\n```php\n$transport = new ExecTransport($apiKey, ['proxy' =\u003e 'https://55.88.22.11:3128']);\n```\n\n**Curl path**\n- It can be useful to specify ```curl``` destination path for ExecTransport. This option is set to 'curl' by default.\n```php\n$transport = new ExecTransport($apiKey, ['curlPath' =\u003e '/usr/bin/curl']);\n```\n\n**Log Server Environment Variables**\n- Server environment variables can be added to error log message metadata. **Note:** This will log all \nsystem environment variables; do not enable if sensitive information such as passwords or keys are stored this way.\n\n ```php\n$handler = new StackifyHandler('application_name', 'environment_name', $transport, true); \n```\n\n## Notes\n\nTo get more error details pass Exception objects to the logger if available:\n```php\ntry {\n    $db-\u003econnect();\ncatch (DbException $ex) {\n    // you may use any key name\n    $logger-\u003eaddError('DB is not available', ['ex' =\u003e $ex]);\n}\n```\n\n## Additional Configuration\nFor additional configurations, you can set on the XML or the PHP File Configuration. Reference for the additional options are located on the stackify logger repository [Stackify PHP Logger - Configuration Settings](stackify/stackify-api-php#configuration-settings)\n\n### Transport Level\n- This applies to all the transports `(ExecTransport, CurlTransport, AgentTransport, AgentSocketTransport)`\n ```php\nuse Monolog\\Logger;\nuse Stackify\\Log\\Monolog\\Handler as StackifyHandler;\n\n$config = array(\n        'CaptureServerVariables' =\u003e false,\n        'CaptureServerVariablesWhitelist' =\u003e '*',\n        'CaptureServerVariablesBlacklist' =\u003e 'REMOTE_ADDR,SERVER_ADDR',\n        ...\n    );\n\n$transport = new ExecTransport($apiKey, [\n    'config' =\u003e $config\n]);\n\n$handler = new StackifyHandler('application_name', 'environment_name', $transport);\n$logger = new Logger('logger');\n$logger-\u003epushHandler($handler);\n```\n### Handler Level\n- This applies to the current Monolog Handler\n\n ```php\nuse Monolog\\Logger;\nuse Stackify\\Log\\Monolog\\Handler as StackifyHandler;\n\n$transport = new ExecTransport($apiKey); // Your selected transport (Can be null which defaults to AgentSocketTransport)\n$logServerVariables = false; // Default\n$config = array(\n        'CaptureServerVariables' =\u003e false,\n        'CaptureServerVariablesWhitelist' =\u003e '*',\n        'CaptureServerVariablesBlacklist' =\u003e 'REMOTE_ADDR,SERVER_ADDR',\n        ...\n);\n\n$handler = new StackifyHandler('application_name', 'environment_name', $transport, $logServerVariables, $config);\n$logger = new Logger('logger');\n$logger-\u003epushHandler($handler);\n```\n#### Handler Level Option\n- **Include Channel**\n    - This will include the logger name or the channel set for the log entry.\n\n ```php\nuse Monolog\\Logger;\nuse Stackify\\Log\\Monolog\\Handler as StackifyHandler;\n\n$transport = new ExecTransport($apiKey); // Your selected transport (Can be null which defaults to AgentSocketTransport)\n$logServerVariables = false; // Default\n$config = array(\n        'IncludeChannel' =\u003e true,\n        ...\n);\n\n$handler = new StackifyHandler('application_name', 'environment_name', $transport, $logServerVariables, $config);\n$logger = new Logger('logger');\n$logger-\u003epushHandler($handler);\n```\n\n- **Include Extra In Context**\n    - This will include the extra property to the context (merging extra to context)\n\n ```php\nuse Monolog\\Logger;\nuse Stackify\\Log\\Monolog\\Handler as StackifyHandler;\n\n$transport = new ExecTransport($apiKey); // Your selected transport (Can be null which defaults to AgentSocketTransport)\n$logServerVariables = false; // Default\n$config = array(\n        'IncludeExtraInContext' =\u003e true,\n        ...\n);\n\n$handler = new StackifyHandler('application_name', 'environment_name', $transport, $logServerVariables, $config);\n$logger = new Logger('logger');\n$logger-\u003epushProcessor(function ($record) {\n      if (empty($record['extra'])) {\n        $record['extra'] = [];\n      }\n      $record['extra']['dummy'] = 1;\n      return $record;\n});\n$logger-\u003epushHandler($handler);\n```\n\n### Symfony\n```yml\nservices:\n    stackify_transport:\n        class: \"Stackify\\\\Log\\\\Transport\\\\CurlTransport\"\n        arguments: [\"api_key\"]\n# Square/Curly Brackets\n    stackify_handler:\n        class: \"Stackify\\\\Log\\\\Monolog\\\\Handler\"\n        arguments: [\"application_name\", \"environment_name\", \"@stackify_transport\", false, { CaptureServerVariables: false, ... }]\n# or\n# Dash/Colon Space\n    stackify_handler:\n        class: \"Stackify\\\\Log\\\\Monolog\\\\Handler\"\n        arguments:\n            - \"application_name\"\n            - \"environment_name\"\n            - \"@stackify_transport\"\n            - false\n            - CaptureServerVariables: false\n              CaptureServerWhitelist: \"*\"\n              CaptureServerBlacklist: null\n              \nmonolog:\n    handlers:\n        stackify:\n            type: service\n            id: stackify_handler\n```\n\n## Troubleshooting\nIf 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).\nNote that ExecTransport does not produce any errors at all, but you can switch it to debug mode:\n```php\n$transport = new ExecTransport($apiKey, ['debug' =\u003e true]);\n```\n\nYou can set it also on the `Logger` level. Setting the `Debug` and `DebugLogPath`\n\n```php\n$config = array(\n        'DebugLogPath' =\u003e '/path/to/log.log',\n        'Debug' =\u003e true\n    );\n\n$logger = new StackifyHandler('application_name', 'environment_name', $transport, $logServerVariables, $config);\n```\n\n## License\n\nCopyright 2019 Stackify, LLC.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackify%2Fstackify-log-monolog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstackify%2Fstackify-log-monolog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackify%2Fstackify-log-monolog/lists"}