[wp-trac] [WordPress Trac] #30934: Create a new API to standardize application logging

WordPress Trac noreply at wordpress.org
Thu Jul 9 10:55:27 UTC 2020

#30934: Create a new API to standardize application logging
 Reporter:  ericlewis    |       Owner:  nacin
     Type:  enhancement  |      Status:  assigned
 Priority:  normal       |   Milestone:
Component:  General      |     Version:
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:

Comment (by thomasprice61):

 Adding my voice to this ...

 === 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
 * 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
 * But ... WordPress could deliver a great logging framework with little

 === 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 WP_DEBUG
   * Optionally allow a developer to configure:
     * log destinations (screen and file. Maybe suggest ''wp-content/logs
     * 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.

Ticket URL: <https://core.trac.wordpress.org/ticket/30934#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list