How can I open/view iOS OSLogs stored on device?

前端 未结 2 1084
时光说笑
时光说笑 2021-01-07 14:23

I\'m creating logs using Apple\'s os.log framework. I\'m just making logs like:

os_log(\"Update: Lat: %{public}f | Long:  %{private}f | Remaini         


        
2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-07 14:42

    You did not specify iOS, macOS, or tvOS in your question, so I am keeping my answer generic across all platforms.

    Review WWDC 2016 - Session 721 - Unified Logging and Activity Tracing.

    Logging data is stored in a new compressed binary format (.tracev3 or .logarchive files), that's what those "numbers" are. You must use Console.app or the log command line tool to open these files.

    You're looking in the wrong place for the log files. From the session video:

    Those files are now stored under /var/db/diagnostics with additional supporting files in /var/db/uuidtext. There are new tools to access that data, there's a new Console, a new log command line tool and one of the things you have to keep in mind is because the data is now stored in a binary format you must use the new tools to access it. So you can no longer grep through logs you have to use our tools to do the surfing through it.

    There's also another new type of file the .logarchive, which is there for portability of log data. Essentially a .logarchive is a collection of information out of /var/db/diagnostics and you uuidtext collected together into a single file that's easier to transfer to email, to attach to bug reports and the like.

    If you redirect stdout or stderr to a file (such as the code in this example), it should be in the Documents directory of your application's sandbox (or whatever directory you specified). Logs written to /var/db/diagnostics are generally unavailable to end users on iOS and tvOS.

提交回复
热议问题