os_log in kernel

I am not having any success with using

os_log
in my KEXT. I've tried with both the
OS_LOG_DEFAULT
log and creating a specific log with
os_log_create
. Regardless of the code I try, I cannot see the KEXT log messages in Console.app. Same with using the command line
log stream --level debug --predicate 'subsystem == "com.example.subsystem"'
(and without subsystem filtering). Am I missing something here?

The

os_log
functions are working in my kext, but it appears that
os_log_create
is not working as expected. Whether I use
OS_LOG_DEFAULT
or a custom subsystem/category from
os_log_create
, the
log
command does not show a subsystem or category attached to os_log messages from my kext. The log config settings do not seem to change the subsystem/category behavior.

As a workaround for what I want (filtering the log stream for my subsystem's messages), I found that I can pass

log stream
a predicate like
--predicate 'senderImagePath == "/Library/Extensions/MyKext.kext/Contents/MacOS/MyKext"'
.

Filed bug report 28948441.

Filed bug report 28948441.

I don’t know what’s going on here, alas, but I wanted to thank you for posting follow ups and for filing that bug report.

Share and Enjoy

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

let myEmail = "eskimo" + "1" + "@apple.com"
Raising a thread from the dead, but for folks having issues with os_log and KEXT.

For some reason I can't add an URL directly, but try https://dmaclach.medium.com/logging-in-kernel-extensions-kexts-on-macos-b558472a9d92 for info.

Filed as FB9069234 for better documentation on os_log.
os_log in kernel
 
 
Q