Viewing os_log messages in device console

前端 未结 4 1400
情话喂你
情话喂你 2021-02-04 01:20

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         


        
4条回答
  •  不要未来只要你来
    2021-02-04 01:26

    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.

提交回复
热议问题