The LXHTTPEndpoint uploads Log Entries to an HTTP service in plaintext format.

Upload and retry management are handled automatically by this Endpoint. Log Entries that do not successfully upload will be queued for another attempt at a later time. Entries are persisted to disk until they are successfully uploaded, including between application runs, so that extended network outages do not cause Log Entries to be lost.

This Endpoint attempts to deliver Log Entries in the order in which they were generated, but because network performance is very unpredictable, this is not guaranteed. It is recommended that developers include a timestamp in this Endpoint’s entryFormatter to facilitate sorting at the HTTP service. The default entryFormatter includes the dateTime property. Developers are also encouraged to investigate the timestamp property.

The HTTP Endpoint is safe to be used in environments featuring concurrency. This Endpoint does some of its work asynchronously to allow better logging performance. Because the HTTP Endpoint takes advantage of asynchronous technologies, Log Entries written to this Endpoint may not appear until slightly after execution has moved on. In other words, if your application attempts to create a Log Entry directly before it crashes, it may not be delivered before the crash occurs. While debugging your application, if the asynchronous nature of this Endpoint is problematic, consider using a synchronous Console Endpoint in addition.

Usage

Initializers

The following initializers are available for LXHTTPEndpoint:

init(request: successCodes: sessionConfiguration: minimumPriorityLevel: dateFormatter: entryFormatter: )

Parameters

request Type: NSURLRequest
Required
The request that will be used when submitting uploads
successCodes Type: Set<Int>
Default: {200, 201, 202, 204}
The set of HTTP status codes the server might respond with to indicate a successful upload
sessionConfiguration Type: NSURLSessionConfiguration
Default: .defaultSessionConfiguration()
The configuration to be used when initializing this Endpoint’s URL session
minimumPriorityLevel Type: LXPriorityLevel
Default: .All
The minimum Priority Level a Log Entry must meet to be accepted by this Endpoint
dateFormatter Type: LXDateFormatter
Default: .standardFormatter()
The formatter used by this Endpoint to serialize a Log Entry’s dateTime property to a string
entryFormatter Type: LXEntryFormatter
Default: .standardFormatter()
The formatter used by this Endpoint to serialize each Log Entry to a string

Developers must supply an NSURLRequest when initializing this Endpoint. This request object will be copied and used to upload each Log Entry to the HTTP service.

Returns an initialized HTTP Endpoint instance.


convenience init(URL: HTTPMethod: successCodes: sessionConfiguration: minimumPriorityLevel: dateFormatter: entryFormatter: )

Parameters

URL Type: NSURL
Required
The URL to upload Log Entries to
HTTPMethod Type: String
Required
The HTTP request method to be used when uploading Log Entries
successCodes Type: Set<Int>
Default: {200, 201, 202, 204}
The set of HTTP status codes the server might respond with to indicate a successful upload
sessionConfiguration Type: NSURLSessionConfiguration
Default: .defaultSessionConfiguration()
The configuration to be used when initializing this Endpoint’s URL session
minimumPriorityLevel Type: LXPriorityLevel
Default: .All
The minimum Priority Level a Log Entry must meet to be accepted by this Endpoint
dateFormatter Type: LXDateFormatter
Default: .standardFormatter()
The formatter used by this Endpoint to serialize a Log Entry’s dateTime property to a string
entryFormatter Type: LXEntryFormatter
Default: .standardFormatter()
The formatter used by this Endpoint to serialize each Log Entry to a string

This convenience initializer allows developers to supply a URL and request method when initializing this Endpoint. The Endpoint will create a basic text/plain NSURLRequest object to be used for all Log Entry uploads. Developers that require more flexibility in configuring upload requests should use the designated initializer above, or determine whether supplying a customized NSURLSessionConfiguration meets their needs.

Returns an initialized HTTP Endpoint instance.