Home > PHP > Log configuration for Laravel multi-line backtrace logs in Datadog

Log configuration for Laravel multi-line backtrace logs in Datadog

April 12th, 2021

Thanks to this link I was able to find this snippet to help quick. I wanted to share this with the world, since it was the only result Google had for this.

    log_processing_rules:
       - type: multi_line
         name: new_log_start_with_date
         pattern: \[\d{4}\-(0?[1-9]|1[012])\-(0?[1-9]|[12][0-9]|3[01])

Here is my full YAML file, for example (in a custom config directory. filename: /etc/datadog-agent/conf.d/custom.d/conf.yaml) - based off a Forge created server. I used wildcards to ensure that it was universally available to all hosts and sites.

logs:
  - type: file
    path: /home/forge/*/storage/logs/*.log
    service: laravel
    source: laravel
    log_processing_rules:
       - type: multi_line
         name: new_log_start_with_date
         pattern: \[\d{4}\-(0?[1-9]|1[012])\-(0?[1-9]|[12][0-9]|3[01])
Categories: PHP
Comments are closed.