xcodebuild does not show output from OSLog in debug level

737 Views Asked by At

I am using xcodebuild to test my application in CI. I invoke it like this:

xcodebuild test -project myapp.xcodeproj -scheme myappTests -destination 'platform=iOS Simulator,name=iPhone 8,OS=14.4'

Text logged with the Logger from OSLog are not shown in debug level. So if I have something like this in my test, it isn't shown in the output of xcodebuild, but I would like to see that:

Logger(subsystem: "a", category: "b").debug("something")

Can I set the logging level of xcodebuild to debug? Messages with error level are shown.

I tried setting xcodebuildDebugLogLevel=3 but that gave me the same logging information.

1

There are 1 best solutions below

2
On

Logger doesn't print debug (and trace) messages to the output because a log level of your subsystem on your simulator is INFO.

You can check this with next steps:

  1. Find your simulator UDID that you use for tests:
$ xcrun simctl list
...
-- iOS 15.2 --
    iPhone 8 (C1D16369-D358-438E-8395-D01C2DE55980) (Shutdown) 
...
  1. Boot it if needed
$ xcrun simctl boot C1D16369-D358-438E-8395-D01C2DE55980
  1. Check a log level of your subsystem name:
$ xcrun simctl spawn C1D16369-D358-438E-8395-D01C2DE55980 log config --subsystem <your-subsystem-name> --status
Mode for '<your-subsystem-name>'  INFO PERSIST_DEFAULT

To change the current log level to DEBUG you can use next command:

$xcrun simctl spawn C1D16369-D358-438E-8395-D01C2DE55980 log config --subsystem <your-subsystem-name> --mode level:debug

Check again:

xcrun simctl spawn C1D16369-D358-438E-8395-D01C2DE55980 log config --subsystem <your-subsystem-name> --status 
Mode for '<your-subsystem-name>'  DEBUG PERSIST_DEFAULT

Now your tests with xcodebuild must have all debug (and trace) messages in the output.

Note: Console.app doesn't provide debug/trace messages even after changes from abobe and it's old known issue with simulators.