Using Console.app for Viewing PHP Logs

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.

10 Replies to “Using Console.app for Viewing PHP Logs”

      1. I’m too old school LOL.

        Way back in the day (in the late ’80s), I used QUED-M which had a regular expression macro language.

        I used it to take a wordstar file with special codes to denote phrases in 3 different character sets (Greek, Hebrew and diacritics) and batch replaced the codes with RTF and opened the file in PageMaker with the all the character sets displayed.

        https://en.wikipedia.org/wiki/QUED/M

  1. Highly recommend checking out PimpMyLog (got introduced to it when I started using HGV). Also try multitail (CLI install with brew) Remote Log (os x app). Almost anything is better than console.app (IMHO, YMMV, etc…)

    1. Never even heard of this before. Definitely interested into looking into some of these options.

      I’ve just defaulted to Console.app since it was there and easy enough for me to read. I make sure mistakes, so there’s really very few lines to parse. Kidding. Gonna check these out :).

Leave a Reply