Remote Logging

Using the PerfectLogger module, events can be logged to a specified remote Perfect Log Server, in addition to the console.

The Perfect Log Server is a stand-alone project that can be deployed on your own servers.

Using in your project

To include the dependency in your project, add the following to your project's Package.swift file:

.Package(url: "", majorVersion: 1),

Now add the import directive to the file you wish to use the logging in:

import PerfectLogger


Three configuration parameters are required:

// Your token
RemoteLogger.token = "<your token>"

// App ID (Optional)
RemoteLogger.appid = "<your appid>"

// URL to access the log server. 
// Note, this is not the full API path, just the host and port.
RemoteLogger.logServer = "http://localhost:8181"


To log events to the log server:

var obj = [String: Any]()
obj["one"] = "donkey"

Linking events with "eventid"

Each log event returns an event id string. If an eventid string is supplied to the directive then it will use the supplied eventid in the log directive instead. This makes it easy to link together related events.

let eid = RemoteLogger.critical(obj), eventid: eid)

The returned eventid is marked @discardableResult and therefore can be safely ignored if not required for re-use.