Swiftpack.co - SwiftyBeaver/SwiftyBeaver-Vapor as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by SwiftyBeaver.
SwiftyBeaver/SwiftyBeaver-Vapor 1.1.0
SwiftyBeaver Logging Provider for Vapor, the server-side Swift web framework
⭐️ 91
🕓 1 week ago
.package(url: "https://github.com/SwiftyBeaver/SwiftyBeaver-Vapor.git", from: "1.1.0")

SwiftyBeaver Logging Provider for Vapor

Swift Vapor 3.x SwiftyBeaver 1.x Slack

Adds the powerful logging of SwiftyBeaver to Vapor for server-side Swift on Linux and Mac.


Add this to the Package.swift of your Vapor project:

dependencies: [
    .package(url: "https://github.com/SwiftyBeaver/SwiftyBeaver-Vapor.git", from: "1.1.0"),
	//...other packages here
targets: [
        .target(name: "App", dependencies: [
            .product(name: "SwiftyBeaverVapor", package: "SwiftyBeaver-Vapor")
	    //...other packages here


In configure.swift:

import SwiftyBeaverVapor
import SwiftyBeaver

/// Called before your application initializes.
public func configure(_ config: inout Config, _ env: inout Environment, _ services: inout Services) throws {
    // ...

    // console logging 
    let consoleDestination = ConsoleDestination()
    try services.register(SwiftyBeaverProvider(destinations: [consoleDestination]))
    // OR console and cloud platform logging
    let consoleDestination = ConsoleDestination()
    let cloudDestination = SBPlatformDestination(appID: "xxx", appSecret: "xxxxxx", encryptionKey: "xxxxx")
    try services.register(SwiftyBeaverProvider(destinations: [consoleDestination, cloudDestination]))

    config.prefer(SwiftyBeaverVapor.self, for: Logger.self)

    // ...

Add the SwiftyBeaver logging destinations you want to use, optionally adjust their defaults like format, color, filter or minimum log level and you are ready to log 🙌


For example, you can log requests as they come in.

func index(_ req: Request) throws -> Future<[Foo]> {

    let logger = try? req.sharedContainer.make(Logger.self)
    logger?.log(req.description, at: .verbose, file: #file, function: #function, line: #line, column: #column)

    return Foo.query(on: req).all()

For more information see the SwiftyBeaver destination docs and how to set a custom logging format.

Output to Xcode 8 Console

Learn more about colored logging to Xcode 8 Console.

Output to File

Learn more about logging to file which is great for Terminal.app fans or to store logs on disk.

Output to Cloud & Mac App


Learn more about logging to the SwiftyBeaver Platform during release!

Learn More

Get support via Github Issues, email and our public Slack channel.


SwiftyBeaverVapor is released under the MIT License.


Stars: 91
Last commit: 1 week ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

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