There are a few possibilities with regards to debug logging in Piwik:

  • Enable logging in the Tracker can be useful to debug Tracking issues or improvements. See the documentation page about enabling Debug logging in the piwik.php tracker
  • Enable logging in the Piwik UI: if you are writing a plugin for example, you would need to output messages on screen (or in a file). To do so, you can edit your config.ini.php and add the following block:

    logger_message[] = “screen”
    logger_error[] = “screen”
    logger_exception[] = “screen”

Values for logger are: “screen”, “file” (logs to tmp/logs), “database” (logs to tables logger_*)

If you wish to debug a live server in production, you can enable logging so that it only outputs the message if you manually append “&debug” in the URL. Under the section [log] in your config.ini.php you can add the following:

log_only_when_debug_parameter = 1

All logging configuration options can be found in config/global.ini.php

  • Enable SQL logging & profiling: to see the list of SQL queries executed by Piwik on any given page or widget, you must first enable logging on screen (see point above). Then, edit your config.ini.php and add the following:

    enable_sql_profiler = 1

Piwik will then output all SQL queries, group them by unique query, and show the total time spent as well as average time spent on each query.