Swiftpack.co - Package - petrpavlik/LogentriesVapor


Logging proxy to Logentries log management for Vapor.



  • Add Logentries as a dependency to Package.swift
dependencies: [
    .Package(url: "https://github.com/petrpavlik/LogentriesVapor.git", majorVersion: 1),
$ swift package update
$ vapor xcode

As a Provider

This option injects Logentries into Vapor's logging system so the logs will include logs generated by Vapor itself and other providers/middleware you use eventually.

  • Initialize Logentries logger
import Vapor
import LogentriesVapor

let drop = Droplet()

// Option 1: load the token from a config file.
try! drop.addProvider(Logentries.self)

// Option 2: Provide the token in code.
drop.addProvider(Logentries(token: "2072e0bd-9812-4625-a01c-1c955d14e16c"))

// ...

// This will appear in your Logentries log
// WARNING: Default Vapor configuration limits logs in production environment to errors and fatals.
drop.log.info("Launching the server")

  • Add configuration file Config/logentries.json if you haven't provided the token in the code. You can set a separate token for production environment by addind a production config file Config/production/logentries.json.
    "token": "2072e0bd-9812-4625-a01c-1c955d14e16c"


This will create an instance of Logentries logger separately from Vapor.

let log = Logentries(token: "2072e0bd-9812-4625-a01c-1c955d14e16c")
log.enabled = LogLevel.all

log.info("Info message")


Q: Is the logging blocking?

A: No, log requests to Logentries are performed asynchronously and all log methods return immediately.

Q: How does the logging work?

A: Each log call performs an HTTPS request to logentries API. It should work fine for a reasonable ammount of logs, switching to a streaming approach is planned for a future release.


Stars: 2
Help us keep the lights on


Used By