As programs run on your Mac, they will output their activity either to the system log or to specific log files, both of which can be viewed using OS X’s Console utility, so if some aspect of your Mac appears to not be working correctly, often the system console is a great tool to use for narrowing down the problem. However, when you open the console you will by default be hit with a barrage of information that can be tough to narrow down, especially if you want to follow the activity of one or more processes.
To help with this, the Console program does include a search feature, which can be used to filter output by keywords, but while useful, this only allows for finding one search term at a time. This may be limiting if you want to view the output from only a couple of processes. If you want to do this, there are several approaches you can take:
Custom system log query
The basic search in the console is quite limited; however, if you press Option-Command-N, then you will see a panel in which you can create more custom searches that include some logic. These then be saved, so with some setup you can create searches to isolate messages from system tools, custom scripts, databases, networking, or other services, without the entry list being cluttered other processes.
New log window
At any time you can press Command-N or choose “New Log Window” from the File menu to create a new view of the console. From here, you can perform a different search to have ongoing monitoring of two separate filtered results.
Sometimes you might want to monitor general activity in the logs, but are receiving a flood of information from one or two processes that makes this somewhat difficult. For these, you can select one of the log entries and click the Ignore Sender toolbar button to prevent any further messages from this process.
Isolate by Sender and Tags
While typing a process name will filter by it, and ignoring senders can cancel out one or two, you can also limit the viewed log entries to specific senders. To do this, click the small triangle button (it is surrounded by a box) in the lower-left of the window, and in the panel that pops up, you will see a list of the more active processes. Checking any combination of these will limit the Console output to the checked processes, and you then use the search field to further filter the console output. In some cases, processes may append tags to their log entries, which can help you isolate them.
Applying to your own scripts
If you are Terminal-savvy and write your own scripts, then there are various resources in OS X for logging output from your script, one of which is the “logger” command. You can use this quickly by running “logger TEXT” to send the TEXT to the console. This can therefore be easily used in scripts to log text, progress, and other aspects of your scripts. In addition, the logger command supports appending tags to the messages it logs, such as the following:
logger -t TAGNAME "This is the message" SCRIPT | logger -t "MYTAG"
This should append the specified tagname to the log entry for the current script, which may show up as either the process sender or tag. Either way, this can give you a means for locating all messages from your scrips, without having to spend time searching for specific text.