Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Drupal 8 monolog logging
# Log to a file by default.
default: ['file']
# Send the php channel to web server's error log and the browser console:
# php: ['error_log', 'browser_console']
# Ignore log entries of "content" channel.
# content: ['null']
# Show memory usage on each log entry:
monolog.processors: ['message_placeholder', 'current_user', 'request_uri', 'memory_usage', 'web']
# Monolog handlers.
class: Monolog\Handler\RotatingFileHandler
arguments: ['../logs/application.log', '30', '200', false]

This comment has been minimized.

Copy link
Owner Author

@janstoeckler janstoeckler commented Jun 2, 2017

  1. Install Drupal 8 monolog module
    composer require drupal/monolog

  2. Enable monolog module

  3. Add this snippet (except the first 4 lines) to sites/default/services.yml, you can also customize it to use different monolog processors & handlers as you desire

  4. Uninstall watchdog module as it will no longer work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment