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

前端 未结 2 1086
时光说笑
时光说笑 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:27

    After following the suggestions of this answer I was able to redirect the logs into the documents directory for my app's sandbox, then I was able to download my container/sandbox using this answer.

    Once I clicked on show package contents I had this:

    I opened the log files using console and the results I got were:

    The Longitude should have showed up as private but since I had it ran through Xcode ie debug mode still the field was rendered public.


    You can also retrieve the logs remotely without any specific setup.

    • trigger a sysdianose.
    • use Airdrop and share the sysdiagnose to your mac
    • unarchive the sysdiagnose file. It will look like this:

    • open the system_logs.logarchive with Console.app
    • it will be as if you're connected to the Console.app. You can filter by subsystem, log level, category and time. It will look like this:

    Note: Searching and filtering is quite slow. Sometimes it takes 2 minutes. It might help if you filter out the dates you don't care about. You can do that by using the filer at the bottom. You have to wait until the loading archive spinner at the bottom right is done loading

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题