I'm trying to get some logging out of my app through Unified Logging (os_log)
Here's the initialization of the log:
var osLog : OSLog = OSLog(subsystem: "com.test.testapp", category: "native-tester")
And here's how I use it:
os_log("iOS App initialized successfully!", log: osLog, type:.info)
When debugging the app normally, the logs appear properly on the console output, but when I look at the device console (Shown in the "Devices and Simulators" window) I don't see them at all.
This article says that you should configure the system to enable the debug logs using
sudo log config --mode "level:debug" --subsystem com.test.testapp
But that didn't seem to make a difference. I'm guessing it's because I'm configuring the mac to view the logs, not the iPad.
How do I view the ipad / iphone logs from os_log in the device console?
Double-click the name of the device that you are running the log file on. Click Console (from the window's main menu). The activity log displays on screen.
You can view all of your Mac's system logs in the Console application, which you'll find in your 'Applications > Utilities' folder. The Console app is divided into an 'All Messages' tab, which displays all the available logs, and an 'Errors and faults' tab, which displays error messages only.
Sends a default-level message to the logging system.
The "Devices and Simulators" window only shows crash reports. Use the Console app or Terminal, via the log --stream
command, to see live log output.
To see the device's live log messages via the Console app, either when running from Xcode or when running from the device directly:
.debug
level messages, make sure to select Include Debug Messages as well. (Without those items selected, the Console displays .default
, .fault
, and .error
level messages only.)If you still don't see the messages, try entering this Terminal command to configure the logging levels for your app:
sudo log config --subsystem com.test.testapp --mode level:debug
This turns on .debug
-level logging for subsystem "com.test.testapp" (which includes .info
and .default
messages).
If you want to persist the messages, rather than the default of memory-only, turn on persistence for the three levels at the same time, like so:
sudo log config --subsystem com.test.testapp --mode level:debug,persist:debug
Regardless of any log settings, though, only crash reports will appear in the "Devices and Simulators" window.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With