AppLoggerKit 1.0: privacy-conscious logging and local diagnostics for Swift, SwiftUI and UIKit

Hi everyone :waving_hand:

I'd like to share AppLoggerKit, an open-source Swift package for structured, privacy-aware app logging. It has no third-party dependencies.

:link: GitHub - eeshuu/AppLoggerKit: Privacy-conscious logging and local diagnostics for Swift, SwiftUI and UIKit: OSLog, JSON Lines files, redaction, search and export. Swift Package Manager, no dependencies. · GitHub

Why I built it

Most apps end up choosing between plain print/OSLog calls and a heavy remote logging SDK. I wanted something in between: logs go to the Apple unified log by default and can optionally go to local files. Sensitive data is redacted before it reaches any destination, and logs stay on the device until the user chooses to export them.

Highlights

  • OSLog output with level mapping and subsystem/category filtering in Console.app
  • Optional JSON Lines file logs with rotation (by size or time), retention limits, file protection and low-storage handling
  • 7 levels from trace to critical. Messages are autoclosures, so calls below the active level cost almost nothing
  • Privacy by default: metadata is classified as .private, .sensitive or .url(...), and tokens, passwords, JWTs and Bearer headers are redacted automatically
  • Correlation IDs through task-local LogContext.withCorrelationID
  • Search and export: LogReader for paging and statistics, LogExporter for redacted JSONL, text or ZIP output
  • Optional SwiftUI/UIKit viewer: LogViewer, LiveLogConsole, and a LogExportButton that uses ShareLink
  • Testing helpers: AppLogger.capturing() for Swift Testing
  • Custom destinations through a simple LogDestination protocol

Quick look

let logger = AppLogger(configuration: .init(
    subsystem: "com.example.app",
    minimumLevel: .info,
    destinations: [OSLogDestination(), FileLogDestination(configuration: .default)]
))

logger.info("Application launched", category: "lifecycle")

// SwiftUI
ContentView().appLogger(logger)

Installation (SPM)

.package(url: "https://github.com/eeshuu/AppLoggerKit.git", from: "1.0.0")

It's split into modules, so you only add what you need: AppLoggerCore, AppLoggerOSLog, AppLoggerFile, AppLoggerUI, AppLoggerTesting.

Requirements: iOS/iPadOS 16+, macOS 13+, Mac Catalyst 16+, Xcode 16 with the Swift 6 toolchain. MIT licensed.

To set expectations, it does not do remote ingestion, analytics or crash reporting. It's meant for local diagnostics.

I'd love your feedback on the API design, especially the privacy and metadata model. Issues, PRs and :star:s are very welcome!