apple/swift-log

A Logging API for Swift

4,046

stars

336

commits

Swift

primary language

Sep 8, 2026

updated

swiftpackageindex.com/apple/swift-log
logging
swift-server
Browse cluster: Swift server-side networking

README

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.

Building with CMake

While Swift Package Manager (SPM) is the primary build system for development and testing, CMake build support is also available for integrated or mixed build environments if needed. Note that tests are not included in the CMake build, they are managed through Swift Package Manager with swift test.

Contributors

(top 30 of 98)

weissi

52 commits

tomerd

48 commits

kukushechkin

35 commits

ktoso

25 commits

apple/swift-log

A Logging API for Swift

4,046

stars

336

commits

Swift

primary language

Sep 8, 2026

updated

swiftpackageindex.com/apple/swift-log
logging
swift-server
Browse cluster: Swift server-side networking

README

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.

Building with CMake

While Swift Package Manager (SPM) is the primary build system for development and testing, CMake build support is also available for integrated or mixed build environments if needed. Note that tests are not included in the CMake build, they are managed through Swift Package Manager with swift test.

Contributors

(top 30 of 98)

weissi

52 commits

tomerd

48 commits

kukushechkin

35 commits

ktoso

25 commits

Languages

Swift

97.4%

CMake

2.6%