Swift macOS App - Enable Info/Debug Logging in Apple Console App
I faced the same problem. Info and debug level messages must be activated in the Console application: Console
> Action
> Include Info Messages
and Include Debug Messages
.
Take a look at Apple documentation at Include info or debug messages.
Viewing os_log messages in device console
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.
os.Logger (os_log) ignores the new privacy string interpolation
You are doing this with the simulator. It only applies when running on a physical device.
Also, the device must not be attached to the debugger.
E.g. here is the console when I watch it while connected to debugger:
When you run this code on a physical device while not connected to the debugger and watch on the macOS console, you will see:
Related Topics
How to Add Documentation to Enum Associated Values in Swift
Get Nil When Looking for File in Subdirectory of Main Bundle
Swift: Search Bar Created at Auto Focus
Swiftui Pass Two Child Views to View
Split Paragraphs into Sentences
How to Re-Order the Realm Table Using Tableview in Swift
Given a Function Parameter of Type [Int]; Can It Be Constrained to Not Be Empty
Why Is Uint64 Max Equal -1 in Swift
How to Encode and Decode the Closures
How to Delete Item from Collection View
Update Nstouchbar on the Fly to Add/Remove Items Programmatically
Implementing a Hash Combiner in Swift
Swiftui: Localizedstringkey with Indices
Get Compiler Error in Swift Indexof()
How How to Perform Multiple Alamofire Requests That Are Finished One After Another
Text from [String] to a Label.Text Isn't Working the First Time
Why Is Casting a Struct to Anyobject Not a Compile Error in Swift