Metal os_log not working

I wanted to try the new logging feature for Metal but could not get it to work.

I modified the PerformingCalculationsOnAGPU example by adding os_log_default.log_debug("Hello thread: %d", index); to log the current thread id. But never saw any messages neither in the console nor in Xcode. I also added the -fmetal-enable-logging flag. I am running the Sequoia release candidate 15.0 (24A335) on M1 Max and Xcode 16.0 (16A242).

What am I missing?

Answered by Graphics and Games Engineer in 803443022

Can you try setting the environment variable MTL_LOG_LEVEL to MTLLogLevelDebug? That will get the command buffer to have the required MTLLogState needed for the logs to be captured by the system and reported in Console.

Accepted Answer

Can you try setting the environment variable MTL_LOG_LEVEL to MTLLogLevelDebug? That will get the command buffer to have the required MTLLogState needed for the logs to be captured by the system and reported in Console.

This worked for me. Thank you!

Metal os_log not working
 
 
Q