swift-log

1.6.4

A Logging API for Swift
apple/swift-log

What's New

1.6.4

2025-07-25T14:02:05Z

What's Changed

SemVer Patch

Other Changes

  • Enable macOS CI on merge to main and daily timer by @rnro in #357
  • Enable macOS CI on pull requests by @rnro in #358
  • Add static SDK CI workflow by @rnro in #355
  • Enable Swift 6.1 jobs in CI by @rnro in #359
  • Remove inaccurate code comment by @gwynne in #349
  • Overhaul README and documentation catalog to introduce best practices by @FranzBusch in #363
  • Add an article how to implement a log handler by @FranzBusch in #364
  • Fix broken link to documentation on README by @simonjbeaumont in #365

New Contributors

Full Changelog: 1.6.3...1.6.4

SwiftLog

This repository contains a logging API implementation for Swift. SwiftLog provides a unified, performant, and ergonomic logging API that can be adopted by libraries and applications across the Swift ecosystem.

Quick Start

The following snippet shows how to add SwiftLog to your Swift Package:

// swift-tools-version: 6.1
import PackageDescription

let package = Package(
    name: "YourApp",
    dependencies: [
        .package(url: "https://github.com/apple/swift-log", from: "1.6.0")
    ],
    targets: [
        .target(
            name: "YourApp",
            dependencies: [
                .product(name: "Logging", package: "swift-log")
            ]
        )
    ]
)

Then start logging:

import Logging

// Create a logger
let logger = Logger(label: "com.example.YourApp")

// Log at different levels
logger.info("Application started")
logger.warning("This is a warning")
logger.error("Something went wrong", metadata: ["error": "\(error)"])

// Add metadata for context
var requestLogger = logger
requestLogger[metadataKey: "request-id"] = "\(UUID())"
requestLogger.info("Processing request")

Available log handler backends

The community has built numerous specialized logging backends.

A great way to discover available log backend implementations is searching the Swift Package Index for the swift-log keyword.

Description

  • Swift Tools 5.9.0
View More Packages from this Author

Dependencies

  • None
Last updated: Sat Sep 06 2025 20:30:28 GMT-0900 (Hawaii-Aleutian Daylight Time)