Where to see logs from my application

Hi folks,

in my application I write some logs over debugPrint or directly over print.

The application is already distributed and some part of functionality failed with application traceback.

I would like to ask user for providing logs from the App. Is it possible to get those logs?

Thanks Petr

Answered by DTS Engineer in 884259022

Thanks for the post, the logs with print will go to your Xcode console while you are debugging. All those are meant to find the issue before releasing the app.

After release you cannot retrieve logs written via print or debugPrint from a distributed app after the fact for privacy.

In Swift, print and debugPrint output directly to standard output (stdout). While this shows up in Xcode when the debugger is attached.

Since you mentioned the app failed with a traceback, the operating system likely generated a Crash Report. You can ask the user to retrieve this specific crash log.

If you want to be able to retrieve logs from users in the future, I would switch to Unified Logging System or a file-based logger and you can ask trusted users to provide you with the sysdiagnose that will contain those logs as Logger API writes to the system's unified logging facility, which persisted to disk and can be retrieved with user’s permission.

Hope this helps. Inviting other developers for their ideas an suggestions.

Albert 
  Worldwide Developer Relations.

Accepted Answer

Thanks for the post, the logs with print will go to your Xcode console while you are debugging. All those are meant to find the issue before releasing the app.

After release you cannot retrieve logs written via print or debugPrint from a distributed app after the fact for privacy.

In Swift, print and debugPrint output directly to standard output (stdout). While this shows up in Xcode when the debugger is attached.

Since you mentioned the app failed with a traceback, the operating system likely generated a Crash Report. You can ask the user to retrieve this specific crash log.

If you want to be able to retrieve logs from users in the future, I would switch to Unified Logging System or a file-based logger and you can ask trusted users to provide you with the sysdiagnose that will contain those logs as Logger API writes to the system's unified logging facility, which persisted to disk and can be retrieved with user’s permission.

Hope this helps. Inviting other developers for their ideas an suggestions.

Albert 
  Worldwide Developer Relations.

What Albert said plus…

At a technical level:

  • Swift’s debugPrint(…) and print(…) default to printing to stdout.
  • When you launch an app as a user would — from the Home screen on iOS, from Finder on the Mac, and so on — the system connects stdin, stdout, and stderr to /dev/null.

For a lot more links and information about the system log, see Your Friend the System Log.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Where to see logs from my application
 
 
Q