Piwik\

Log

Logging utility class.

Log entries are made with a message and log level. The logging utility will tag each log entry with the name of the plugin that's doing the logging. If no plugin is found, the name of the current class is used.

You can log messages using one of the public static functions (eg, 'error', 'warning', 'info', etc.).

Currently, Matomo (formerly Piwik) supports the following logging backends:

  • screen: logging to the screen
  • file: logging to a file
  • database: logging to Matomo's MySQL database

Messages logged in the console will always be logged to the console output.

Logging configuration

The logging utility can be configured by manipulating the INI config options in the [log] section.

The following configuration options can be set:

  • log_writers[]: This is an array of log writer IDs. The three log writers provided by Matomo core are file, screen, database, errorlog, and syslog. You can get more by installing plugins. The default value is screen.
  • log_level: The current log level. Can be ERROR, WARN, INFO, DEBUG, or VERBOSE. Log entries made with a log level that is as or more severe than the current log level will be outputted. Others will be ignored. The default level is WARN.
  • logger_file_path: For the file log writer, specifies the path to the log file to log to or a path to a directory to store logs in. If a directory, the file name is piwik.log. Can be relative to Matomo's root dir or an absolute path. Defaults to tmp/logs.
  • logger_syslog_ident: If configured to log to syslog, mark them with this identifier string. This acts as an easy-to-find tag in the syslog.

Methods

The class defines the following methods:

  • getInstance() ash; Returns the singleton instance for the derived class. Inherited from Singleton
  • error() — Logs a message using the ERROR log level.
  • warning() — Logs a message using the WARNING log level.
  • info() — Logs a message using the INFO log level.
  • debug() — Logs a message using the DEBUG log level.
  • verbose() — Logs a message using the VERBOSE log level.

getInstance()

Returns the singleton instance for the derived class. If the singleton instance has not been created, this method will create it.

Signature

error()

Logs a message using the ERROR log level.

See Also

  • \Psr\Log\LoggerInterface::error()

Signature

  • It accepts the following parameter(s):

    • $message
  • It does not return anything or a mixed result.

warning()

Logs a message using the WARNING log level.

See Also

  • \Psr\Log\LoggerInterface::warning()

Signature

  • It accepts the following parameter(s):

    • $message
  • It does not return anything or a mixed result.

info()

Logs a message using the INFO log level.

See Also

  • \Psr\Log\LoggerInterface::info()

Signature

  • It accepts the following parameter(s):

    • $message
  • It does not return anything or a mixed result.

debug()

Logs a message using the DEBUG log level.

See Also

  • \Psr\Log\LoggerInterface::debug()

Signature

  • It accepts the following parameter(s):

    • $message
  • It does not return anything or a mixed result.

verbose()

Logs a message using the VERBOSE log level.

See Also

  • \Psr\Log\LoggerInterface::debug()

Signature

  • It accepts the following parameter(s):

    • $message
  • It does not return anything or a mixed result.