@mnapoli opened this Issue on November 9th 2014 Member

Current issues with the logger:

  1. static methods + singleton
  2. global config not overridable by environment (unless I missed how to do that): e.g. in CLI we might want to log to stdout but in HTTP API we don't want to log into the JSON response #6612
  3. backends are hardcoded and can't be customized (e.g. logging to email, Slack, New Relic, Graylog…)
  4. we can't specify different logging levels for each backend (e.g. log to email on errors only, log to file for anything above INFO)
  5. we don't comply to standards which requires new contributors to learn Piwik logger's specificities, and which means the logger can't be changed because Piwik Core and plugins are coupled to it
  6. we need to maintain our own logger when many other loggers exist, are maintained and have more features


  1. refactor the logger to an object instance (instead of static methods), injectable with dependency injection
  2. configure the logger with DI config, which should have a global config + specific config per environment
  3. use Monolog for example, which comes with so many backend adapters
  4. Monolog supports a huge list of backends
  5. we should use a PSR-3 compatible logger so that we decouple from a specific implementation and its usage is more standard (i.e. simpler for contributors)
  6. this point is covered above (i.e. reuse an existing library like Monolog)

The challenge would be to keep BC, so if we indeed switch to Monolog we would need to implement our own message formatters to support sprintf and also implement our own adapters for the DB logging probably.

I'm not saying we should do it today, but at least the discussion can be opened.

Linked discussions, for reference: #110, #6209, #6612

@tsteur commented on November 10th 2014 Owner

:+1: for using monolog but still keep the API (as mentioned convert to an object instance etc) and not breaking anything

Replacing our logger with monolog is on the second place on my "most wanted" todo list and I am looking forward to seeing it in Piwik

@mattab commented on November 10th 2014 Owner

i'm very excited by possibilities of logging Tracker events to various backends in #6209 which kinda requires this new logger first so big :+1:

@tsteur commented on November 10th 2014 Owner

I can't wait to use the FingersCrossedHandler ;)

@mattab commented on November 11th 2014 Owner

I can't wait to use the FingersCrossedHandler ;)

:+1: this looks so useful!

@mnapoli commented on December 19th 2014 Member

The pull request was merged, what is left for me to do:

@mnapoli commented on December 21st 2014 Member


@mattab commented on December 21st 2014 Owner

Beautiful! :-)

This Issue was closed on December 21st 2014
Powered by GitHub Issue Mirror