When working with PHP, there are some great libraries and tools that make it easy for logging notices, warnings, errors, and so on within our code.

For what it’s worth, I think PHP does a pretty good job of doing this on its own, but if you need to write your custom logging code, there are plenty of off-the-shelf libraries that are helpful.

But that’s not the gist of this post. Instead, just as I think it’s important to make sure we’re providing reliable logging information, I think it’s important that we’re able to view said logs, as well.

Viewing PHP Logs

If you’re on a Mac, then I recommend using Console.app (and it ships with OS X) as yet another way of viewing your PHP logs.

Activity Monitor

Yes, there are a lot of other ways to dump errors out into the screen such as echo and var_dump (though I don’t think those are the best ways to go about debugging your application).

But Console.app makes it a bit easier to monitor continually, clear, refresh, and watch log data as it happens in real-time on your system. It’s easy to read (because of the structure of the PHP log itself), and it displays the errors as they occur.

This makes it possible to stop dumping information out on your screen while working on something in WordPress and keep it relegated to its own file.

Where Is My PHP Log?

If you’re interested in using Console.app for something like this, you’re going to need to know where your PHP log resides. Depending on your set up and where your server and PHP installation live will indicate where the log file exists.

It would be somewhat cumbersome to try to list all of the places the log file could be located especially because each of us has our preferred setup. The two best places I recommend checking are:

  1. Create a file that contains <?php php_info(); ?>  and then see where it’s specified based on the output of that function.
  2. Look in your php.ini file for the error_log value.

Either of those should provide you with all of the information you need to know as to where logging resides. From there, locate the file and select to open it within Console.app.