How to Create a Logging System in Swift

I'm fairly new to iOS development, and I would like to create a simple Logging System in Swift for debugging purposes.


What I have so far is an app that asks the user for their username, password, and a unique key. It then sends that data to an API to authenticate, and the API sends back some data related to the user.


Everything works, I just want to create a Log that sends data to the Console App to help troubleshoot and debug in the near future, and progression of the app.


Any references or code samples would be greatly appreciated.


Thanks.

Answered by DTS Engineer in 214301022

As KMT said, you should definitely look at the new unified logging facility we introduced in iOS 10. I recommend that you watch WWDC 2016 Session 721 Unified Logging and Activity Tracing, which is a good introduction to the topic. You may need to add some app-specific infrastructure around that facility, but it’s a good place to start.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

> I would like to create a simple Logging System in Swift for debugging purposes.


No need.


See https://developer.apple.com/reference/os/logging

Accepted Answer

As KMT said, you should definitely look at the new unified logging facility we introduced in iOS 10. I recommend that you watch WWDC 2016 Session 721 Unified Logging and Activity Tracing, which is a good introduction to the topic. You may need to add some app-specific infrastructure around that facility, but it’s a good place to start.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thanks a lot KMT and eskimo!


This makes things much easier.

How to Create a Logging System in Swift
 
 
Q