0

How can you configure XCGLogger to log so that you can access log files from individual devices being used for testing?

Marcus Leon
  • 55,199
  • 118
  • 297
  • 429

1 Answers1

1

I use CocoaLumberjack (another logging framework) in my apps but the following applies to any logging framework that supports logging to a file (including XGCLogger).

Setup your logging framework to log to a file (in addition to any other destination you might need).

Then add an option to your app somewhere appropriate that lets the user submit diagnostic information to you. When the user chooses this option your app can use MFMailComposeViewController to send you an email. Pre-populate the "to" field with your email address. Add the log file(s) as attachments to the email. Set the subject as desired (something like "MyCooApp Diagnostic Info"). You can also pre-populate the email message with additional details. I include the user's locale and timezone, the device name and model, and the version of iOS.

The user can add any additional info to the email message and tap Send. You get a nice email with the logs and other details.

If you don't want to take the email route, setup your web server with a special page that accepts file posts. Then have your app post the log files to your web server when the user chooses the "submit diagnostic info" option in your app.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • Thanks. Also Is it possible to get the log off the device when directly connected via Xcode? – Marcus Leon Oct 22 '16 at 22:55
  • Xcode lets you download the entire app sandbox for development apps via the Devices window. I don't think this work for apps installed via Test Flight and certainly not for the App Store. Another option is to store the log files in the app's Documents folder and enable file sharing for the app. Then you can access the Documents folder through iTunes. This works for dev, test, and App Store apps. – rmaddy Oct 22 '16 at 22:58