Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#50619 closed enhancement (duplicate)

Provide a Logging Framework for WordPress developers

Reported by: thomasprice61's profile thomasprice61 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:


WordPress currently has:

  • debugging by including in wp-config.php: WP_DEBUG, WP_DEBUG_LOG, WP_DEBUG_DISPLAY which will generate a log file, display on screen, etc
  • access to the PHP function error_log() to record information in WP_DEBUG
  • a folder wp-content/logs/ but there are no guidelines if or how it should be used.

Logging Best Practice generally includes determining the:

  • Purpose and scope of what should be logged: for debugging, for security, for business rules such as exception handling, etc.
  • Log structure and characteristics, such as log levels (critical, error, warning, information, debug), etc.
  • Output of logging such as presentation, alerting, processes, etc
  • Management of log information, resources, tools and processes

Logging Framework:

  • WordPress currently only provides basic logging for a developer. There is a large gap between this and Best Practice.
  • Plugins can close this gap for those needing comprehensive logging capabilities
  • But ... WordPress could deliver a great logging framework with little effort

Proposed Enhancement:

  • Develop a core function wp_log()
  • Characteristics should:
    • Include in its simplest (default) use case a wrapper for error_log() to send a message to the WP_DEBUG_LOG file
    • Optionally allow a developer to configure:
      • log destinations (screen and file. Maybe suggest wp-content/logs/plugin-name/log-file-name)
      • log structure (example: [YYYYMMDD hh:mm:ss]level message)
    • It could also include hooks so 3rd parties can further enhance logging (example: allow a 3rd party to configure rolling log files, log to external log sinks, etc)

Suggested approach:

  • While the wp_log() function and source code must have no commercial implications, asking existing commercial organisations (current plugin providers or organisations such as splunk) that provide logging services to develop the function seems quite reasonable. They get kudos, WordPress gets enhanced.

Change History (1)

#1 @ocean90
4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Hello @thomasprice61, welcome to WordPress Trac!

We already have a similar request in #30934. Could you please add your thoughts on this ticket so we can keep the discussion in one place? Thank you!

Note: See TracTickets for help on using tickets.