MonologDatadog is a Datadog Log handler for Monolog. It enables you to send logs directly to HTTP with Curl.
- Datadog Account
- Datadog Api Key
- Php 7.1+
- Php-curl
- Send Monolog logs directly to HTTP with Curl
- Automatically JSON Formatted
Install the latest version with
composer require guspio/monolog-datadog
<?php
use Monolog\Logger;
use MonologDatadog\Handler\DatadogHandler;
// Add your [Datadog Api Key]
$apiKey = 'YOUR-DATADOG-API-KEY';
$attributes = [
'hostname' => 'YOUR_HOSTNAME', // Default: $_SERVER['SERVER_NAME']
'source' => 'php', // Default: php
'service' => 'YOUR-SERVICE' // Default: Monolog channel name
];
$logger = new Logger('datadog-channel');
$datadogLogs = new DatadogHandler($apiKey, $attributes, Logger::INFO);
$logger->pushHandler($datadogLogs);
$logger->info('i am an info');
$logger->warning('i am a warning..');
$logger->error('i am an error ');
$logger->notice('i am a notice');
$logger->emergency('i am an emergency');