Does WordPress provide different levels of logging?

(I come from a Java development background, so please excuse my lack of PHP and WordPress knowledge.)

My understanding of logging in WordPress is that it must first be enabled in wp-config.php and then calls to error_log() can be seen and read.

But logging is not just about errors. It is very useful when developing and debugging to be able to log. For this reason many Java logging libraries (e.g. SLF4J) provide the ability to log at the following levels:

  • TRACE (lowest)
  • DEBUG
  • INFO
  • WARN
  • ERROR (highest)

You can then configure the logging level that you wish to see in the log. For example when developing you would like to see DEBUG and above, but when running in production you probably just want to see WARN and above.

Is there something equivalent in WordPress? Logging everything as an error does not seem right.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Your understand is correct. WordPress doesn’t have levels beyond Warning and Error from PHP.

Wonolog, a WordPress wrapper for Monolog, expands the default error logging into the levels you require. You can also expand the logging by adding your own custom debuging alerts and level.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x