Unified Logging from the Kernel

This thread has been locked by a moderator.

I recently had cause to futz around with using the new unified logging mechanism (

<os/log.h>
) from kernel code and I learnt some things that I figured I might share:
  • Within the kernel

    os_log_create
    always returns
    NULL
    , so you can’t create your own logging handle. You have to use
    OS_LOG_DEFAULT
    .
  • This limits your ability to configure logging. You always get the standard configuration, meaning that

    OS_LOG_TYPE_INFO
    and
    OS_LOG_TYPE_DEBUG
    always go to memory.
  • The channel used by kernel logging is shared by all kernel code.

  • If kernel code logs too frequently, log messages will be dropped (this is no different from previous kernel logging mechanisms, and is necessary because the kernel can’t block waiting for the user space daemon to clear the log).

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
Up vote post of eskimo
870 views