unified logging and activity tracing - apple inc. › videos › wwdc › 2016 › 721wh2… ·...
TRANSCRIPT
![Page 1: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/1.jpg)
© 2016 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.
Logging for the future
System Frameworks #WWDC16
Session 721
Unified Logging and Activity Tracing
Steven Szymanski Core OS EngineeringMatthieu Lucas System Applications
![Page 2: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/2.jpg)
Agenda
IntroductionLogging ConceptsDemoUsing the Unified SystemToolsBest PracticesGathering LogsDeprications
![Page 3: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/3.jpg)
Introduction
![Page 4: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/4.jpg)
Background
![Page 5: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/5.jpg)
Background
In 2014 Apple introduced Activity Tracing
![Page 6: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/6.jpg)
Background
In 2014 Apple introduced Activity TracingWe also introduced the concept of Faults and Errors
![Page 7: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/7.jpg)
Background
In 2014 Apple introduced Activity TracingWe also introduced the concept of Faults and ErrorsWe recognize that Apple has several logging APIs
![Page 8: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/8.jpg)
Goals
![Page 9: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/9.jpg)
Goals
One common, efficient logging mechanism for both user and kernel mode
![Page 10: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/10.jpg)
Goals
One common, efficient logging mechanism for both user and kernel modeMaximize information collected while minimizing observer effect
![Page 11: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/11.jpg)
Goals
One common, efficient logging mechanism for both user and kernel modeMaximize information collected while minimizing observer effect• Compressing data
![Page 12: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/12.jpg)
Goals
One common, efficient logging mechanism for both user and kernel modeMaximize information collected while minimizing observer effect• Compressing data• Deferring work and data collection
![Page 13: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/13.jpg)
Goals
One common, efficient logging mechanism for both user and kernel modeMaximize information collected while minimizing observer effect• Compressing data• Deferring work and data collection• Managing log message lifecycle
![Page 14: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/14.jpg)
Goals
One common, efficient logging mechanism for both user and kernel modeMaximize information collected while minimizing observer effect• Compressing data• Deferring work and data collection• Managing log message lifecycle
We want as much logging on all the time as possible
![Page 15: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/15.jpg)
Goals
One common, efficient logging mechanism for both user and kernel modeMaximize information collected while minimizing observer effect• Compressing data• Deferring work and data collection• Managing log message lifecycle
We want as much logging on all the time as possibleDesign privacy into the system
![Page 16: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/16.jpg)
Features
![Page 17: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/17.jpg)
Features
Improved categorization and filtering of log messages
![Page 18: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/18.jpg)
Features
Improved categorization and filtering of log messagesLogging system collects caller information for you
![Page 19: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/19.jpg)
Features
Improved categorization and filtering of log messagesLogging system collects caller information for youNew builtin type specifiers - simplifies log message preparation
![Page 20: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/20.jpg)
Features
Improved categorization and filtering of log messagesLogging system collects caller information for youNew builtin type specifiers - simplifies log message preparationNew Console application and command-line tool
![Page 21: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/21.jpg)
Features
Improved categorization and filtering of log messagesLogging system collects caller information for youNew builtin type specifiers - simplifies log message preparationNew Console application and command-line toolSupported on macOS, iOS, tvOS, watchOS, and Simulators
![Page 22: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/22.jpg)
Features
Improved categorization and filtering of log messagesLogging system collects caller information for youNew builtin type specifiers - simplifies log message preparationNew Console application and command-line toolSupported on macOS, iOS, tvOS, watchOS, and SimulatorsSupport for Objective-C, C++ and C
![Page 23: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/23.jpg)
Features
Improved categorization and filtering of log messagesLogging system collects caller information for youNew builtin type specifiers - simplifies log message preparationNew Console application and command-line toolSupported on macOS, iOS, tvOS, watchOS, and SimulatorsSupport for Objective-C, C++ and C Swift support in upcoming seed
![Page 24: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/24.jpg)
Current Console
![Page 25: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/25.jpg)
Console Revisited…
![Page 26: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/26.jpg)
Console Revisited…
![Page 27: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/27.jpg)
Logging Concepts
![Page 28: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/28.jpg)
Adoption
![Page 29: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/29.jpg)
Adoption
If you want to use the new Unified Logging system• Build with the macOS 10.12, iOS 10.0, tvOS 10.0 or watchOS 3.0 SDK• Legacy APIs (NSLog, asl_log_message, syslog…) redirected into new system• Log data will be in new format and location
![Page 30: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/30.jpg)
Adoption
If you want to use the new Unified Logging system• Build with the macOS 10.12, iOS 10.0, tvOS 10.0 or watchOS 3.0 SDK• Legacy APIs (NSLog, asl_log_message, syslog…) redirected into new system• Log data will be in new format and location
If you don’t want to use the new Unified Logging system• Build with macOS10.11, iOS 9.0, tvOS 9.0 and watchOS 2.0 SDK• No changes
![Page 31: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/31.jpg)
New File Formats
![Page 32: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/32.jpg)
New File Formats
Log data is kept in a compressed binary format: .tracev3 files
![Page 33: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/33.jpg)
New File Formats
Log data is kept in a compressed binary format: .tracev3 filesStored under /var/db/diagnostics/ with support in /var/db/uuidtext
![Page 34: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/34.jpg)
New File Formats
Log data is kept in a compressed binary format: .tracev3 filesStored under /var/db/diagnostics/ with support in /var/db/uuidtextNew tools to access the stored and live log messages
![Page 35: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/35.jpg)
New File Formats
Log data is kept in a compressed binary format: .tracev3 filesStored under /var/db/diagnostics/ with support in /var/db/uuidtextNew tools to access the stored and live log messages• Because data is stored in binary format, you MUST use new tools to access files
![Page 36: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/36.jpg)
New File Formats
Log data is kept in a compressed binary format: .tracev3 filesStored under /var/db/diagnostics/ with support in /var/db/uuidtextNew tools to access the stored and live log messages• Because data is stored in binary format, you MUST use new tools to access files
New .logarchive format for portability of logs
![Page 37: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/37.jpg)
New File Formats
Log data is kept in a compressed binary format: .tracev3 filesStored under /var/db/diagnostics/ with support in /var/db/uuidtextNew tools to access the stored and live log messages• Because data is stored in binary format, you MUST use new tools to access files
New .logarchive format for portability of logs
![Page 38: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/38.jpg)
NEWSubsystems and Categories
![Page 39: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/39.jpg)
NEWSubsystems and Categories
Log messages can be associated with a subsystem and category
![Page 40: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/40.jpg)
NEWSubsystems and Categories
Log messages can be associated with a subsystem and categoryCan be used to control how log messages are filtered and displayed
![Page 41: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/41.jpg)
NEWSubsystems and Categories
Log messages can be associated with a subsystem and categoryCan be used to control how log messages are filtered and displayedA subsystem can contain multiple categories
![Page 42: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/42.jpg)
NEWSubsystems and Categories
Log messages can be associated with a subsystem and categoryCan be used to control how log messages are filtered and displayedA subsystem can contain multiple categoriesYou can use as many subsystems and categories as needed
![Page 43: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/43.jpg)
NEWSubsystems and Categories
Log messages can be associated with a subsystem and categoryCan be used to control how log messages are filtered and displayedA subsystem can contain multiple categoriesYou can use as many subsystems and categories as needed
Example:
![Page 44: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/44.jpg)
NEWSubsystems and Categories
Log messages can be associated with a subsystem and categoryCan be used to control how log messages are filtered and displayedA subsystem can contain multiple categoriesYou can use as many subsystems and categories as needed
Subsystem Category
com.your-company.your-application setup, inprogress, teardown
Example:
![Page 45: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/45.jpg)
NEWSubsystems and Categories
Log messages can be associated with a subsystem and categoryCan be used to control how log messages are filtered and displayedA subsystem can contain multiple categoriesYou can use as many subsystems and categories as needed
Subsystem Category
com.your-company.your-application setup, inprogress, teardown
com.your-company.test.your-application test
Example:
![Page 46: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/46.jpg)
Logging Behavior NEW
![Page 47: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/47.jpg)
Logging Behavior
Each log message has a level determined by the API used
NEW
![Page 48: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/48.jpg)
Logging Behavior
Each log message has a level determined by the API used• Three basic levels—Default, Info, Debug
NEW
![Page 49: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/49.jpg)
Logging Behavior
Each log message has a level determined by the API used• Three basic levels—Default, Info, Debug• Two special levels—Fault, Error
NEW
![Page 50: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/50.jpg)
Logging Behavior
Each log message has a level determined by the API used• Three basic levels—Default, Info, Debug• Two special levels—Fault, Error
Each basic level has two characteristics that can be set for system, subsystem, or category
NEW
![Page 51: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/51.jpg)
Logging Behavior
Each log message has a level determined by the API used• Three basic levels—Default, Info, Debug• Two special levels—Fault, Error
Each basic level has two characteristics that can be set for system, subsystem, or category• Is is enabled? (Default messages are always enabled)
NEW
![Page 52: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/52.jpg)
Logging Behavior
Each log message has a level determined by the API used• Three basic levels—Default, Info, Debug• Two special levels—Fault, Error
Each basic level has two characteristics that can be set for system, subsystem, or category• Is is enabled? (Default messages are always enabled)• Is it stored to disk or memory?
NEW
![Page 53: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/53.jpg)
Logging Behavior
Each log message has a level determined by the API used• Three basic levels—Default, Info, Debug• Two special levels—Fault, Error
Each basic level has two characteristics that can be set for system, subsystem, or category• Is is enabled? (Default messages are always enabled)• Is it stored to disk or memory?
The levels are hierarchical
NEW
![Page 54: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/54.jpg)
Logging Behavior
Each log message has a level determined by the API used• Three basic levels—Default, Info, Debug• Two special levels—Fault, Error
Each basic level has two characteristics that can be set for system, subsystem, or category• Is is enabled? (Default messages are always enabled)• Is it stored to disk or memory?
The levels are hierarchical• So setting Debug to go to disk implies that Info will also go to disk
NEW
![Page 55: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/55.jpg)
Logging Behavior
Each log message has a level determined by the API used• Three basic levels—Default, Info, Debug• Two special levels—Fault, Error
Each basic level has two characteristics that can be set for system, subsystem, or category• Is is enabled? (Default messages are always enabled)• Is it stored to disk or memory?
The levels are hierarchical• So setting Debug to go to disk implies that Info will also go to disk
Behavior can be customized by installing profiles or, on macOS, via log command
NEW
![Page 56: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/56.jpg)
Standard Behavior NEW
![Page 57: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/57.jpg)
Standard Behavior
Message Level Enabled Destination
DEFAULT LEVEL ALWAYS DISK
INFO LEVEL YES MEMORY
DEBUG LEVEL NO N/A
NEW
![Page 58: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/58.jpg)
Standard Behavior
Message Level Enabled Destination
DEFAULT LEVEL ALWAYS DISK
INFO LEVEL YES MEMORY
DEBUG LEVEL NO N/A
ERROR ALWAYS DISK
FAULT ALWAYS DISK
NEW
![Page 59: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/59.jpg)
Privacy NEW
![Page 60: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/60.jpg)
Privacy
Prevent accidental logging of Personally Identifiable Information (PII)
NEW
![Page 61: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/61.jpg)
Privacy
Prevent accidental logging of Personally Identifiable Information (PII)Dynamic strings, collections, arrays, etc. are assumed to be private
NEW
![Page 62: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/62.jpg)
Faults and Errors NEW
![Page 63: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/63.jpg)
Faults and Errors
We do extra work saving additional information on Fault or Error
NEW
![Page 64: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/64.jpg)
Faults and Errors
We do extra work saving additional information on Fault or Error Errors represent issues discovered within a given application/library
NEW
![Page 65: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/65.jpg)
Faults and Errors
We do extra work saving additional information on Fault or Error Errors represent issues discovered within a given application/libraryFaults represent more global problems in the system
NEW
![Page 66: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/66.jpg)
Faults and Errors
We do extra work saving additional information on Fault or Error Errors represent issues discovered within a given application/libraryFaults represent more global problems in the systemFaults and Error log information is captured into a separate set of log files
NEW
![Page 67: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/67.jpg)
Architecture
![Page 68: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/68.jpg)
Architecture
Process A
Process B
4 k4 kBuffer
4 k4 kBuffer
![Page 69: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/69.jpg)
Architecture
Process A logd
Compressor
Process B
4 k4 kBuffer
BufferBufferBufferBufferCompressed Buffer
4 k4 kBuffer
![Page 70: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/70.jpg)
Architecture
Process A logd
Compressor
Process B
4 k4 kBufferMemory Only Buffer
Regular Log Data
Fault and Error Log Data
Others
Compressed Log Files
BufferBufferBufferBufferCompressed Buffer
4 k4 kBuffer
![Page 71: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/71.jpg)
Architecture
Process A logd
Compressor
Process B
4 k4 kBufferMemory Only Buffer
Regular Log Data
Fault and Error Log Data
Others“Live” log stream
Compressed Log Filesdiagnosticd
BufferBufferBufferBufferCompressed Buffer
4 k4 kBuffer
![Page 72: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/72.jpg)
Architecture
Process A logd
Compressor
Process B
Profile can change routing and rules for given applications or subsystems
4 k4 kBufferMemory Only Buffer
Regular Log Data
Fault and Error Log Data
Others“Live” log stream
Compressed Log Filesdiagnosticd
BufferBufferBufferBufferCompressed Buffer
4 k4 kBuffer
![Page 73: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/73.jpg)
DemoConsole demo
![Page 74: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/74.jpg)
Using the Unified System
![Page 75: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/75.jpg)
API Destination Description
os_log Disk Default logging level that is always captured
os_log_info Memory Additional information (defaults to memory-only buffers)
os_log_debug Off Debug level content (off-by default)
os_log_error Disk Process local error
os_log_fault Disk System-level error (usually involves multiple processes)
os_log_create n/a Create a log object for custom behaviors
Summary of New APIs NEW
![Page 76: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/76.jpg)
Creating a Log Object NEW
![Page 77: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/77.jpg)
Creating a Log Object NEW
os_log_t log = os_log_create("com.your_company.subsystem", "network");
Create thread-safe singleton object that controls behavior of log messages
![Page 78: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/78.jpg)
Creating a Log Object NEW
os_log_t log = os_log_create("com.your_company.subsystem", "network");
Create thread-safe singleton object that controls behavior of log messages Defaults to system-behavior
![Page 79: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/79.jpg)
Creating a Log Object NEW
os_log_t log = os_log_create("com.your_company.subsystem", "network");
Create thread-safe singleton object that controls behavior of log messages Defaults to system-behaviorUsage
os_log(log, "This happened");
![Page 80: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/80.jpg)
Creating a Log Object NEW
os_log_t log = os_log_create("com.your_company.subsystem", "network");
Create thread-safe singleton object that controls behavior of log messages Defaults to system-behaviorUsage
os_log(log, "This happened");
Reference to category and subsystem stored with every log message
![Page 81: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/81.jpg)
Creating a Log Object NEW
os_log_t log = os_log_create("com.your_company.subsystem", "network");
Create thread-safe singleton object that controls behavior of log messages Defaults to system-behaviorUsage
os_log(log, "This happened");
Reference to category and subsystem stored with every log messageOr use OS_LOG_DEFAULT • For messages not associated with subsystem/category
![Page 82: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/82.jpg)
Creating a Log Object NEW
os_log_t log = os_log_create("com.your_company.subsystem", "network");
Create thread-safe singleton object that controls behavior of log messages Defaults to system-behaviorUsage
os_log(log, "This happened");
Reference to category and subsystem stored with every log messageOr use OS_LOG_DEFAULT • For messages not associated with subsystem/category
![Page 83: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/83.jpg)
Built-in Type Formatters NEW
We all spend too much code converting binary information to strings to log
![Page 84: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/84.jpg)
Built-in Type Formatters NEW
We all spend too much code converting binary information to strings to log
Built-in decoding for common values"%{time_t}d" or "%{errno}d"
![Page 85: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/85.jpg)
Built-in Type Formatters NEW
We all spend too much code converting binary information to strings to log
Built-in decoding for common values"%{time_t}d" or "%{errno}d"Arbitrary binary data using a new format type"%.*P"
![Page 86: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/86.jpg)
Built-in Type Formatters NEW
We all spend too much code converting binary information to strings to log
Built-in decoding for common values"%{time_t}d" or "%{errno}d"Arbitrary binary data using a new format type"%.*P"
Built-in decoding for binary-types“%{uuid_t}.16P"
![Page 87: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/87.jpg)
Example Type Formatters
Type Format String Example Outputtime_t %{time_t}d 2016-01-12 19:41:37
timeval %{timeval}.*P 2016-01-12 19:41:37.774236
timespec %{timespec}.*P 2016-01-12 19:41:37.774236823
errno %{errno}d Broken pipe
uuid_t %{uuid_t}.16P %{uuid_t}.*P 10742E39-0657-41F8-AB99-878C5EC2DCAA
sockaddr %{network:sockaddr}.*P fe80::f:86ff:fee9:5c16 17.43.23.87
in_addr %{network:in_addr}d 17.43.23.87
in6_addr %{network:in6_addr}.16P fe80::f:86ff:fee9:5c16
NEW
![Page 88: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/88.jpg)
Per Parameter Privacy NEW
![Page 89: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/89.jpg)
Per Parameter Privacy
Privacy is handled on a parameter by parameter basis
NEW
![Page 90: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/90.jpg)
Per Parameter Privacy
Privacy is handled on a parameter by parameter basisScalars and static strings are assumed to be public
NEW
![Page 91: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/91.jpg)
Per Parameter Privacy
Privacy is handled on a parameter by parameter basisScalars and static strings are assumed to be publicDynamic strings, collections, and objects are assumed to be private
NEW
![Page 92: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/92.jpg)
Per Parameter Privacy
Privacy is handled on a parameter by parameter basisScalars and static strings are assumed to be publicDynamic strings, collections, and objects are assumed to be private
NEW
Can be overridden on a per-parameter basis
"%{public}@" or "%{private}d"
![Page 93: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/93.jpg)
Per Parameter Privacy
Privacy is handled on a parameter by parameter basisScalars and static strings are assumed to be publicDynamic strings, collections, and objects are assumed to be private
NEW
Can be overridden on a per-parameter basis
"%{public}@" or "%{private}d"Combine privacy and formatting
"%{public, uuid_t}.16P”
![Page 94: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/94.jpg)
/*
* Log Message Simplification
*/
![Page 95: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/95.jpg)
/*
* Log Message Simplification
*/
// Old way:
![Page 96: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/96.jpg)
/*
* Log Message Simplification
*/
// Old way:
if (LogLevelEnabled(info)) {
![Page 97: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/97.jpg)
/*
* Log Message Simplification
*/
// Old way:
if (LogLevelEnabled(info)) {
uuid_string_t uuid_str;
uuid_unparse_upper(uuid, uuid_str);
![Page 98: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/98.jpg)
/*
* Log Message Simplification
*/
// Old way:
if (LogLevelEnabled(info)) {
uuid_string_t uuid_str;
uuid_unparse_upper(uuid, uuid_str);
char *addr_desc = _convert_sockaddr(&sa);
![Page 99: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/99.jpg)
/*
* Log Message Simplification
*/
// Old way:
if (LogLevelEnabled(info)) {
uuid_string_t uuid_str;
uuid_unparse_upper(uuid, uuid_str);
char *addr_desc = _convert_sockaddr(&sa);
NSLog(@"%s (%s:%d) - fd: %d, uuid: %s, IP: %s”,
__PRETTY_FUNCTION__, __FILE__, __LINE__, fd, uuid_st, addr_desc);
![Page 100: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/100.jpg)
/*
* Log Message Simplification
*/
// Old way:
if (LogLevelEnabled(info)) {
uuid_string_t uuid_str;
uuid_unparse_upper(uuid, uuid_str);
char *addr_desc = _convert_sockaddr(&sa);
NSLog(@"%s (%s:%d) - fd: %d, uuid: %s, IP: %s”,
__PRETTY_FUNCTION__, __FILE__, __LINE__, fd, uuid_st, addr_desc);
free(addr_desc);
![Page 101: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/101.jpg)
/*
* Log Message Simplification
*/
// Old way:
if (LogLevelEnabled(info)) {
uuid_string_t uuid_str;
uuid_unparse_upper(uuid, uuid_str);
char *addr_desc = _convert_sockaddr(&sa);
NSLog(@"%s (%s:%d) - fd: %d, uuid: %s, IP: %s”,
__PRETTY_FUNCTION__, __FILE__, __LINE__, fd, uuid_st, addr_desc);
free(addr_desc);
}
![Page 102: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/102.jpg)
/*
* Log Message Simplification
*/
// Old way:
if (LogLevelEnabled(info)) {
uuid_string_t uuid_str;
uuid_unparse_upper(uuid, uuid_str);
char *addr_desc = _convert_sockaddr(&sa);
NSLog(@"%s (%s:%d) - fd: %d, uuid: %s, IP: %s”,
__PRETTY_FUNCTION__, __FILE__, __LINE__, fd, uuid_st, addr_desc);
free(addr_desc);
}
// New way:
![Page 103: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/103.jpg)
/*
* Log Message Simplification
*/
// Old way:
if (LogLevelEnabled(info)) {
uuid_string_t uuid_str;
uuid_unparse_upper(uuid, uuid_str);
char *addr_desc = _convert_sockaddr(&sa);
NSLog(@"%s (%s:%d) - fd: %d, uuid: %s, IP: %s”,
__PRETTY_FUNCTION__, __FILE__, __LINE__, fd, uuid_st, addr_desc);
free(addr_desc);
}
// New way:
os_log_info(OS_LOG_DEFAULT,
![Page 104: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/104.jpg)
/*
* Log Message Simplification
*/
// Old way:
if (LogLevelEnabled(info)) {
uuid_string_t uuid_str;
uuid_unparse_upper(uuid, uuid_str);
char *addr_desc = _convert_sockaddr(&sa);
NSLog(@"%s (%s:%d) - fd: %d, uuid: %s, IP: %s”,
__PRETTY_FUNCTION__, __FILE__, __LINE__, fd, uuid_st, addr_desc);
free(addr_desc);
}
// New way:
os_log_info(OS_LOG_DEFAULT,
"fd: %d, uuid: %{uuid_t}.16P, IP: %{network:sockaddr}.*P”,
![Page 105: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/105.jpg)
/*
* Log Message Simplification
*/
// Old way:
if (LogLevelEnabled(info)) {
uuid_string_t uuid_str;
uuid_unparse_upper(uuid, uuid_str);
char *addr_desc = _convert_sockaddr(&sa);
NSLog(@"%s (%s:%d) - fd: %d, uuid: %s, IP: %s”,
__PRETTY_FUNCTION__, __FILE__, __LINE__, fd, uuid_st, addr_desc);
free(addr_desc);
}
// New way:
os_log_info(OS_LOG_DEFAULT,
"fd: %d, uuid: %{uuid_t}.16P, IP: %{network:sockaddr}.*P”,
fd, uuid, sa->sa_len, &sa);
![Page 106: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/106.jpg)
/* * Example Code */
![Page 107: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/107.jpg)
/* * Example Code */
os_log_t general_log = os_log_create("com.apple.logging.example", "general");
![Page 108: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/108.jpg)
/* * Example Code */
os_log_t general_log = os_log_create("com.apple.logging.example", "general");os_log_t time_log = os_log_create("com.apple.logging.example", "timestamp");
![Page 109: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/109.jpg)
/* * Example Code */
os_log_t general_log = os_log_create("com.apple.logging.example", "general");os_log_t time_log = os_log_create("com.apple.logging.example", "timestamp");
os_log(general_log, "running example code”);
![Page 110: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/110.jpg)
/* * Example Code */
os_log_t general_log = os_log_create("com.apple.logging.example", "general");os_log_t time_log = os_log_create("com.apple.logging.example", "timestamp");
os_log(general_log, "running example code”);
os_log_info(general_log, "processing file %{public}s”, filename);
![Page 111: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/111.jpg)
/* * Example Code */
os_log_t general_log = os_log_create("com.apple.logging.example", "general");os_log_t time_log = os_log_create("com.apple.logging.example", "timestamp");
os_log(general_log, "running example code”);
os_log_info(general_log, "processing file %{public}s”, filename);
int fd = open(filename, O_RDONLY);if (fd < 0) { os_log_error(general_log, "Cannot open file %{public}s - %{errno}d", filename, errno); . . . }
![Page 112: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/112.jpg)
/* * Example Code */
os_log_t general_log = os_log_create("com.apple.logging.example", "general");os_log_t time_log = os_log_create("com.apple.logging.example", "timestamp");
os_log(general_log, "running example code”);
os_log_info(general_log, "processing file %{public}s”, filename);
int fd = open(filename, O_RDONLY);if (fd < 0) { os_log_error(general_log, "Cannot open file %{public}s - %{errno}d", filename, errno); . . . }
struct stat sb;if (fstat(fd, &sb) < 0) { os_log_fault(general_log, "Failed to fstat %{public}s - %{errno}d", filename, errno); . . . }
![Page 113: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/113.jpg)
/* * Example Code */
os_log_t general_log = os_log_create("com.apple.logging.example", "general");os_log_t time_log = os_log_create("com.apple.logging.example", "timestamp");
os_log(general_log, "running example code”);
os_log_info(general_log, "processing file %{public}s”, filename);
int fd = open(filename, O_RDONLY);if (fd < 0) { os_log_error(general_log, "Cannot open file %{public}s - %{errno}d", filename, errno); . . . }
struct stat sb;if (fstat(fd, &sb) < 0) { os_log_fault(general_log, "Failed to fstat %{public}s - %{errno}d", filename, errno); . . . }
os_log_info(time_log, "status for file %{public}s, atime:%{timespec}.*P, mtime:%{timespec}.*P, ctime:%{timespec}.*P",
filename, sizeof(struct timespec), &sb.st_atimespec, sizeof(struct timespec), &sb.st_mtimespec, sizeof(struct timespec), &sb.st_ctimespec);
![Page 114: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/114.jpg)
Activity API Improvements
![Page 115: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/115.jpg)
Activity API Improvements
Activities are now objects that can be stored and re-used
![Page 116: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/116.jpg)
Activity API Improvements
Activities are now objects that can be stored and re-used• Direct control of activity relationships during creation
![Page 117: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/117.jpg)
Activity API Improvements
Activities are now objects that can be stored and re-used• Direct control of activity relationships during creation
New API to auto-scope activities within your code
![Page 118: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/118.jpg)
Improved Activity APIs
os_activity_create Creates a new activity object
os_activity_scope Makes an execution block a part of an activity
os_activity_apply Invokes a block scoped to a given activity
os_activity_label_useraction Label an activity as a user action (UI-based activities)
NEW
![Page 119: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/119.jpg)
/* * New Activity API Example */
![Page 120: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/120.jpg)
/* * New Activity API Example */
os_activity_t init_activity = os_activity_create("Init", OS_ACTIVITY_CURRENT, OS_ACTIVITY_FLAG_DEFAULT);
![Page 121: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/121.jpg)
/* * New Activity API Example */
os_activity_t init_activity = os_activity_create("Init", OS_ACTIVITY_CURRENT, OS_ACTIVITY_FLAG_DEFAULT);
os_activity_t verify_activity = os_activity_create("Verify", init_activity, OS_ACTIVITY_FLAG_DEFAULT);
![Page 122: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/122.jpg)
/* * New Activity API Example */
os_activity_t init_activity = os_activity_create("Init", OS_ACTIVITY_CURRENT, OS_ACTIVITY_FLAG_DEFAULT);
os_activity_t verify_activity = os_activity_create("Verify", init_activity, OS_ACTIVITY_FLAG_DEFAULT);
if (isReady) { os_activity_scope(verify_activity); // All of the following work is done under “verification activity scope” . . .}
![Page 123: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/123.jpg)
/* * New Activity API Example */
os_activity_t init_activity = os_activity_create("Init", OS_ACTIVITY_CURRENT, OS_ACTIVITY_FLAG_DEFAULT);
os_activity_t verify_activity = os_activity_create("Verify", init_activity, OS_ACTIVITY_FLAG_DEFAULT);
if (isReady) { os_activity_scope(verify_activity); // All of the following work is done under “verification activity scope” . . .} // This is not part of that activity
![Page 124: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/124.jpg)
/* * New Activity API Example */
os_activity_t init_activity = os_activity_create("Init", OS_ACTIVITY_CURRENT, OS_ACTIVITY_FLAG_DEFAULT);
os_activity_t verify_activity = os_activity_create("Verify", init_activity, OS_ACTIVITY_FLAG_DEFAULT);
if (isReady) { os_activity_scope(verify_activity); // All of the following work is done under “verification activity scope” . . .} // This is not part of that activity
os_activity_apply(init_activity, ^{ // do some work based on the “init_activity” . . .});
![Page 125: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/125.jpg)
Tools
![Page 126: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/126.jpg)
Console NEW
![Page 127: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/127.jpg)
Console
View live content from a system
NEW
![Page 128: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/128.jpg)
Console
View live content from a systemOpen log archives
NEW
![Page 129: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/129.jpg)
Console
View live content from a systemOpen log archivesNew Activity centric view of logging and tracing
NEW
![Page 130: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/130.jpg)
Console
View live content from a systemOpen log archivesNew Activity centric view of logging and tracingAdvanced filtering and searching
NEW
![Page 131: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/131.jpg)
Console
View live content from a systemOpen log archivesNew Activity centric view of logging and tracingAdvanced filtering and searchingDevice support
NEW
![Page 132: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/132.jpg)
log Command Line Tool NEW
![Page 133: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/133.jpg)
log Command Line Tool
Same functionality as Console from the command line
NEW
![Page 134: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/134.jpg)
log Command Line Tool
Same functionality as Console from the command lineStream live log messages
NEW
![Page 135: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/135.jpg)
log Command Line Tool
Same functionality as Console from the command lineStream live log messages
$ log stream
NEW
![Page 136: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/136.jpg)
log Command Line Tool
Same functionality as Console from the command lineStream live log messages
$ log stream$ log stream --predicate 'eventMessage contains "my message"'
NEW
![Page 137: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/137.jpg)
log Command Line Tool
Same functionality as Console from the command lineStream live log messages
$ log stream$ log stream --predicate 'eventMessage contains "my message"'Display a log file or archive
NEW
![Page 138: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/138.jpg)
log Command Line Tool
Same functionality as Console from the command lineStream live log messages
$ log stream$ log stream --predicate 'eventMessage contains "my message"'Display a log file or archive
$ log show system_logs.logarchive
NEW
![Page 139: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/139.jpg)
log Command Line Tool
Same functionality as Console from the command lineStream live log messages
$ log stream$ log stream --predicate 'eventMessage contains "my message"'Display a log file or archive
$ log show system_logs.logarchiveEnable debug for your subsystem on macOS
NEW
![Page 140: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/140.jpg)
log Command Line Tool
Same functionality as Console from the command lineStream live log messages
$ log stream$ log stream --predicate 'eventMessage contains "my message"'Display a log file or archive
$ log show system_logs.logarchiveEnable debug for your subsystem on macOS
$ log config --mode "level:debug" --subsystem com.mycorp.myapp
NEW
![Page 141: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/141.jpg)
log Command Line Tool
Same functionality as Console from the command lineStream live log messages
$ log stream$ log stream --predicate 'eventMessage contains "my message"'Display a log file or archive
$ log show system_logs.logarchiveEnable debug for your subsystem on macOS
$ log config --mode "level:debug" --subsystem com.mycorp.myapp
NEW
![Page 142: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/142.jpg)
Coming Soon NEW
![Page 143: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/143.jpg)
Coming Soon
Tools for accessing new log information from 10.11 are coming soon
NEW
![Page 144: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/144.jpg)
Coming Soon
Tools for accessing new log information from 10.11 are coming soonBut… in the meantime
NEW
![Page 145: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/145.jpg)
Coming Soon
Tools for accessing new log information from 10.11 are coming soonBut… in the meantime
$ xcrun simctl spawn booted log show system_logs.logarchive
NEW
![Page 146: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/146.jpg)
Coming Soon
Tools for accessing new log information from 10.11 are coming soonBut… in the meantime
$ xcrun simctl spawn booted log show system_logs.logarchive
NEW
![Page 147: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/147.jpg)
Best Practices
![Page 148: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/148.jpg)
Logging Etiquette
![Page 149: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/149.jpg)
Logging Etiquette
Ensure messages contain only information useful for debugging
![Page 150: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/150.jpg)
Logging Etiquette
Ensure messages contain only information useful for debuggingLet us do the formatting for you—leverage built-in formatters
![Page 151: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/151.jpg)
Logging Etiquette
Ensure messages contain only information useful for debuggingLet us do the formatting for you—leverage built-in formattersAvoid creating wrapper functions for os_log* APIs
![Page 152: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/152.jpg)
Logging Etiquette
Ensure messages contain only information useful for debuggingLet us do the formatting for you—leverage built-in formattersAvoid creating wrapper functions for os_log* APIsLog only what you need from collections (Dictionaries, Arrays, etc.)
![Page 153: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/153.jpg)
Logging Etiquette
Ensure messages contain only information useful for debuggingLet us do the formatting for you—leverage built-in formattersAvoid creating wrapper functions for os_log* APIsLog only what you need from collections (Dictionaries, Arrays, etc.)Avoid logging in tight code loops
![Page 154: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/154.jpg)
Using os_log Family of APIs
![Page 155: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/155.jpg)
Using os_log Family of APIs
Use os_log to log critical details to help debug issues
![Page 156: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/156.jpg)
Using os_log Family of APIs
Use os_log to log critical details to help debug issuesUse os_log_info for additional info that will be captured during error or fault
![Page 157: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/157.jpg)
Using os_log Family of APIs
Use os_log to log critical details to help debug issuesUse os_log_info for additional info that will be captured during error or faultUse os_log_debug for high-volume debugging during development
![Page 158: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/158.jpg)
Using os_log Family of APIs
Use os_log to log critical details to help debug issuesUse os_log_info for additional info that will be captured during error or faultUse os_log_debug for high-volume debugging during developmentUse os_log_error to cause additional information capture from app
![Page 159: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/159.jpg)
Using os_log Family of APIs
Use os_log to log critical details to help debug issuesUse os_log_info for additional info that will be captured during error or faultUse os_log_debug for high-volume debugging during developmentUse os_log_error to cause additional information capture from appUse os_log_fault to cause additional information capture from system
![Page 160: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/160.jpg)
Gathering Logs
![Page 161: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/161.jpg)
Using sysdiagnose NEW
![Page 162: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/162.jpg)
Using sysdiagnose
sysdiagnose is the preferred method to capture data for bug reports
NEW
![Page 163: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/163.jpg)
Using sysdiagnose
sysdiagnose is the preferred method to capture data for bug reports• Unified Logging data in system_logs.archive
NEW
![Page 164: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/164.jpg)
Using sysdiagnose
sysdiagnose is the preferred method to capture data for bug reports• Unified Logging data in system_logs.archive
You can use key-chord to trigger
NEW
![Page 165: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/165.jpg)
Using sysdiagnose
sysdiagnose is the preferred method to capture data for bug reports• Unified Logging data in system_logs.archive
You can use key-chord to triggersysdiagnose on Apple Watch will trigger on both Apple Watch and iPhone
NEW
![Page 166: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/166.jpg)
Using sysdiagnose
sysdiagnose is the preferred method to capture data for bug reports• Unified Logging data in system_logs.archive
You can use key-chord to triggersysdiagnose on Apple Watch will trigger on both Apple Watch and iPhoneTransfer from device using iTunes
NEW
![Page 167: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/167.jpg)
Using sysdiagnose
sysdiagnose is the preferred method to capture data for bug reports• Unified Logging data in system_logs.archive
You can use key-chord to triggersysdiagnose on Apple Watch will trigger on both Apple Watch and iPhoneTransfer from device using iTunesThis is the file to send to Apple (either Radar or Developer Technical Support)
NEW
![Page 168: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/168.jpg)
Key-chords for sysdiagnose NEW
Mac OS Shift + Control + Option + Command + Period (.)
iOS Volume Up + Volume Down + Power Slight vibration on iPhone to indicate start
watchOS Press and hold Digital Crown + Side Button for 1 second A screen shot is triggered if not held long enough. Slight haptic to indicate start.
tvOS Play/Pause + Volume Down On older remote controls for Apple TV, must be held for 5 seconds
![Page 169: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/169.jpg)
Deprecations
![Page 170: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/170.jpg)
Deprecation of Legacy logging APIs
![Page 171: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/171.jpg)
Deprecation of Legacy logging APIs
All ASL logging APIs are superseded by the new APIs
![Page 172: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/172.jpg)
Deprecation of Legacy logging APIs
All ASL logging APIs are superseded by the new APIsNew APIs for searching new log data will not be made public this release
![Page 173: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/173.jpg)
Deprecation of Legacy logging APIs
All ASL logging APIs are superseded by the new APIsNew APIs for searching new log data will not be made public this release• No equivalent asl_search functionality
![Page 174: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/174.jpg)
os_activity_start Use os_activity_create and os_activity_scope / os_activity_apply
os_activity_end Use os_activity_create and os_activity_scope / os_activity_apply
os_activity_set_breadcrumb Use os_activity_label_useraction
os_trace_with_payload Use os_log*
Deprecated Activity APIs
![Page 175: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/175.jpg)
Summary
![Page 176: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/176.jpg)
Summary
The new Unified Logging system is
![Page 177: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/177.jpg)
Summary
The new Unified Logging system is• Faster
![Page 178: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/178.jpg)
Summary
The new Unified Logging system is• Faster• Easier to use
![Page 179: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/179.jpg)
Summary
The new Unified Logging system is• Faster• Easier to use• Gives you more control
![Page 180: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/180.jpg)
Summary
The new Unified Logging system is• Faster• Easier to use• Gives you more control
But requires using new APIs and new tools
![Page 181: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/181.jpg)
Related Sessions
Fix Bugs Faster Using Activity Tracing WWDC 2014
![Page 182: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/182.jpg)
More Information
https://developer.apple.com/wwdc16/721
![Page 183: Unified Logging and Activity Tracing - Apple Inc. › videos › wwdc › 2016 › 721wh2… · Logging for the future System Frameworks #WWDC16 Session 721 Unified Logging and](https://reader036.vdocuments.site/reader036/viewer/2022062603/5f036ead7e708231d4092d5a/html5/thumbnails/183.jpg)