Swiftpack.co -  Kitura-Next/LoggerAPI as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
✔︎ Logger protocol
.package(url: "https://github.com/Kitura-Next/LoggerAPI.git", from: "IBM-2019")


APIDoc Apache 2 Slack Status


A logger protocol that provides a common logging interface for different kinds of loggers. In addition, a class with a set of static functions for logging within your code is provided.

Kitura uses this API throughout its implementation when logging.


Add dependencies

Add the LoggerAPI package to the dependencies within your application’s Package.swift file. Substitute "x.x.x" with the latest LoggerAPI release:

.package(url: "https://github.com/Kitura-Next/LoggerAPI.git", from: "x.x.x")

Add LoggerAPI to your target's dependencies:

.target(name: "example", dependencies: ["LoggerAPI"]),

Import package

import LoggerAPI

Log messages

Add log messages to your application:

Log.warning("This is a warning.")
Log.error("This is an error.")

Define a logger

You need to define a logger in order to output these messages. You may wish to write your own Logger implementation, or you can use HeliumLogger that writes to standard output:

import LoggerAPI
import HeliumLogger

let myLogger = HeliumLogger(.info)
Log.logger = myLogger

You can find out more about HeliumLogger here.

Logging messages to swift-log

You can direct your log messages to be logged via swift-log by setting the swiftLogger property:

import LoggerAPI
import Logging

let myLogger = Logging.Logger(label: "myLogger")
myLogger.logLevel = .notice
Log.swiftLogger = myLogger

If both logger and swiftLogger are set, then log messages will be sent to both logging backends. The log level configured for a LoggerAPI Logger and a swift-log Logger are independent, so may be used to log at different levels.

Note that because the hierarchy of log levels defined by LoggerAPI and swift-log is slightly different, a mapping is defined between the levels. See the documentation for Log.isLogging() for details.

Swift version

Requires Swift 5.1 or newer. You can download this version of the Swift binaries by following this link. Compatibility with other Swift versions is not guaranteed.

API documentation

For more information visit our API reference.


We love to talk server-side Swift, and Kitura. Join our Slack to meet the team!


This library is licensed under Apache 2.0. Full license text is available in LICENSE.


Stars: 0
Last commit: 22 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.


Release Notes

22 weeks ago
  • Update testing to include Swift 5.3.1
  • Remove support for Swift 4

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API