Series: Unified Logging and Activity Tracing

Unified Logging and Activity Tracing

In 2016 Apple introduced a new framework for logging. The new Unified Logging system spans all operating systems and levels and offers some additional improvements over existing solutions. Apple continues to recommend that we switch to this new system. In this series we will see how to adopt the new logging system, where to find our messages, and how to tweak the system to display messages we are interested in. We'll also see how to use Activity Tracing so we can get a big picture of what's happening in our applications.

Length: about 1 hour


1. Introduction to the Unified Logging Framework

Subscribers only

A high level overview of the new Unified Logging system, which covers the benefits of the new system, a high level overview of how it works, and some things to consider when adopting the new system.

2. Using os_log to Log Messages

Subscribers only

In this episode we show how you adopt the Unified Logging framework in code by using the OSLog type to define your log subsystems and categories, and how to use os_log to actually log events and messages.

3. Private Data and the log Utility

Subscribers only

In this episode we talk about public versus private data (and how to change the defaults). We also look at using the log command line tool for a deeper understanding of the unified logging system and how we can tweak it for our needs.

4. Streaming Logs with the log Tool

Subscribers only is a nice way of viewing logs, but most of this power (and more) is builtin to the log utility from the command line. In this episode we will see how to stream debug logs from the simulator, as well as how to retrieve logs from customer or tester devices out in the field by triggering a sysdiagnose.

5. Activity Tracing in Swift

Subscribers only

Activity Tracing can help give you the big picture when looking at logs. By marking logical activities with os_activity, you can create a hierarchy of tasks that roll up the log statements that occurred for that activity. Unfortunately, using os_activity from Swift is not really supported yet, so we will see how to use a wrapper to make it a little easier, then dive in deep into C interop to see how all the pieces work.

6. Using Signposts to Diagnose Performance Issues

Subscribers only

Signposts are a special part of the Unified Logging and Activity Tracing system. They allow you to mark point-in-time events that occur in your code, or track the duration of operations by specifying the begin and end for an activity. These can be visualized in Instruments to get a rich, high level view of how these operations are performing, how often they are occurring, and how long they are taking. In this episode we will see how to add signposts to an app and how to view these signposts in Instruments.