Marcus Leon Marcus Leon - 1 month ago 16
Swift Question

XGCLogger: Retrieve logs from device?

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

Answer

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.

Comments