X
Simply launch this command in your root laravel project :
composer require myli/laravel-datadog-logger
I would highly suggest you to use the DataDog Agent Style rather than the Api Style because one laravel log = one api call which is bad for performances.
-
Firstly, install the agent by following this guide here
-
Add in your
config/logging.php
the following underchannels
tab:'datadog-agent' => [ 'driver' => 'single', 'path' => storage_path('logs/laravel-json-datadog-' . php_sapi_name() . '.log'), 'tap' => [\Myli\DatadogLogger\DataDogFormatter::class,], 'permission' => 0664, 'level' => 'info', // choose your minimum level of logging. ],
-
Add
LOG_CHANNEL="datadog-agent"
in your.env
file OR includedatadog-agent
channel into your stack log channel. -
Enable logs by setting
logs_enabled: true
in the defaultdatadog.yml
file on the server where the project is hosted. -
Choose only one config between those 3 files to put in
/etc/datadog-agent/conf.d/laravel.d/
(create thelaravel.d
folder if it doesn't exist) : -
Restart your DataDog Agent and watch your result here.
Notes: At this time the source
metadata from the DataDogFormatter is not taken care by DataDog so that's why we are specifying it in the /etc/datadog-agent/conf.d/laravel.d/conf.yaml
file.
-
Add in your
config/logging.php
the following underchannels
tab:'datadog-api' => [ 'driver' => 'custom', 'via' => \Myli\CreateDataDogLogger::class, 'apiKey' => env('DATADOG_API_KEY'), 'region' => 'eu', // eu or us 'level' => 'info', // choose your minimum level of logging. 'bubble' => true, ],
-
And finally add
LOG_CHANNEL="datadog-api"
in your.env
file OR includedatadog-api
channel into your stack log channel. -
The only custom options are
region
(values can beus|eu
) andapiKey
which you can find here
We have included the awesome symfony/thanks
composer package as a dev
dependency. Let your OS package maintainers know you appreciate them by starring
the packages you use. Simply run composer thanks after installing this package.
(And not to worry, since it's a dev-dependency it won't be installed in your
live environment.)
The Laravel DataDog Logger is open-sourced software licensed under the MIT license.
Repository proudly created by