Last active
April 19, 2023 14:53
-
-
Save kyletaylored/c133cf719bf64edc0075bb0d7133688e to your computer and use it in GitHub Desktop.
How to integrate Monolog with New Relic in Drupal 9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"require": { | |
"drupal/monolog": "^2.2", | |
"newrelic/monolog-enricher": "^2.0" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parameters: | |
monolog.channel_handlers: | |
default: | |
handlers: | |
- name: "new_relic_buffered" | |
processors: | |
- "drupal_message_placeholder" | |
- "new_relic_processor" | |
- name: "new_relic_error" | |
services: | |
monolog.processor.new_relic_processor: | |
class: NewRelic\Monolog\Enricher\Processor | |
# Log API New Relic Processor | |
# Has build in buffering for New Relic requests. | |
monolog.handler.new_relic_log: | |
class: NewRelic\Monolog\Enricher\Handler | |
arguments: ["200", false] | |
# Log API New Relic Handler (buffered) | |
# Buffered handler waits for all messages before batch sending. | |
monolog.handler.new_relic_buffered: | |
class: Monolog\Handler\BufferHandler | |
arguments: ["@monolog.handler.new_relic_log"] | |
# Error Event New Relic Handler | |
# Uses newrelic_notice_error to send logs to the Triage Errors inbox. | |
monolog.handler.new_relic_error: | |
class: Monolog\Handler\NewRelicHandler | |
arguments: ["300", false] | |
# Rotating file | |
# Store logs in Pantheon's default log directory. | |
monolog.handler.rotating_file: | |
class: Monolog\Handler\RotatingFileHandler | |
arguments: ["/logs/php/application.log", "15", "200", false] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Pantheon specific settings. | |
if (!empty($_ENV['PANTHEON_ENVIRONMENT'])) { | |
// Load monolog config. | |
$monolog_services = __DIR__ . '/monolog.services.yml'; | |
if (file_exists($monolog_services)) { | |
$settings['container_yamls'][] = $monolog_services; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment