Skip to main content

How to view kernel logs in OS X

How to view kernel logs is OS X

You can use the command line tool log for this.

This command accepts a predicate argument that can be used to , well build predicates, that when evaluates to true, the log message will be printed. It takes a command argument that decides how the logs are to be displayed. For instance

log stream

produces a streaming output of the log. That is new log messages are displayed as they come (asynchronously).

log show

displays messages from the log history.

log --process 0

displays messages from process with ID 0, which is kernel. This can be used to display all kext log messages.

log show --predicate 'processID == 0'

displays messages printed by processID 0, which is the kernel process. This is the same as the previous command.

To display messages from a driver, you may use the sender predicate filter argument. So if your driver is named mytestdriver, you may display messages from it using the command:

log stream --predicate 'sender == "mytestdriver"'

Note that we're only specifying the actual executable name (value of CFBundleExecutable in the drivers plist file) and not the bundle identifier.

Replacing stream with show will show past messages from the log.

If you want to filter messages that contain a specific string pattern, say "user request":

log stream --predicate 'sender == "mytestdriver" and message contains "user request"'

Note that you also use the Applications -> Uitlities -> Console app to get similar results, but from a GUI.