First make sure you have installed Monolog.
You will also need a Datadog account and an access to their Log Management product.
First you need to make sure the config/packages/presta_datadog.yaml
file exists, or to create it.
You will have to set the 3 following required options:
# config/packages/presta_datadog.yaml
presta_datadog:
env: '%env(APP_ENV)%'
api_key: 'Your Datadog API key'
service_name: 'Your project name'
The
service_name
value is nothing but a suggestion, feel free to set any name that will help you identify your application's logs in the Datadog Log Management platform.
You can find all available options in the Configuration Reference file.
Once the bundle is configured, you need to tell Monolog to use it's handler.
Let's assume you want to use it only in the production environment.
# config/packages/monolog.yaml
when@prod:
monolog:
handlers:
datadog:
type: 'service'
id: 'presta_datadog.handler'
Once setup properly, any time your application logs a message, it will be passed to the handler.
If the channel the message was logged to is in the configured excluded channels (see the Configuration Reference file), the log record will be skipped.
If the log level is less than error, nothing will be sent through the Datadog logs API. The log record will be stacked in the handler instead.
At the end of the process, if no messages with a level equal to or higher than error has been logged, the stack is cleared and nothing else happens.
However if at any point of the process a message is logged with a level equal to or higher than error, all the log records previously stacked by the handler will be sent through a POST
request on the Datadog logs API.
From now on, any log that reaches at least the error level will trigger sending all previously stacked logs to Datadog through their logs API.
You may return to the README.md or read the Configuration Reference file.