Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Viewing os_log messages in device console

Tags:

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?

like image 228
Nitay Avatar asked Oct 10 '17 06:10

Nitay


People also ask

How do I find the console log on my Iphone?

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.

How do I check my console for error messages on Mac?

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.

What is Os_log?

Sends a default-level message to the logging system.


1 Answers

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:

  • Open Console.app.
  • Click on the device's name in the left side panel, under "Devices".
  • Select Action, then Include Info Messages from the menu. If you are also using .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.

like image 60
leanne Avatar answered Oct 16 '22 14:10

leanne