swift-log is a free, open source monitoring & observability project written in Swift and released under Apache-2.0. It has 4,050 GitHub stars, 344 forks and 26 open issues, and was last pushed 13 hours ago. On this registry it ranks #103 of 191 tracked projects in Monitoring & Observability, with 5 head-to-head comparisons available.

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.

Frequently asked questions

Is swift-log free to use?

swift-log is open source under the Apache-2.0 licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does swift-log do?

A Logging API for Swift

What is swift-log written in?

swift-log is primarily written in Swift. Its source is publicly available at https://github.com/apple/swift-log, and it has 4,050 GitHub stars.