The UnifiedLogHandler creates an OSLog for each Logger in your application or its libraries. It uses the application’s bundle identifier and the Logger‘s label as the OSLog subsystem and category, respectively.
For example:
let logger = Logger(label: "APIClient")
logger.info("Something happened")
UnifiedLogHandler
UnifiedLogHandler is a SwiftLog backend that uses Apple’s Unified Logging System.
You can instruct
SwiftLogto use theUnifiedLogHandlerbackend as follows:The
UnifiedLogHandlercreates anOSLogfor eachLoggerin your application or its libraries. It uses the application’s bundle identifier and theLogger‘s label as theOSLogsubsystem and category, respectively.For example:
Prints the following output:
You can also use metadata when logging. For example:
Prints the following output:
Installation
Using the Swift Package Manager
Add UnifiedLogHandler as a dependency to your
Package.swiftfile. For more information, see the Swift Package Manager documentation.Help & Feedback
UnifiedLogHandler.