The LXLogHTTPEndpoint 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. However, pending uploads are not persisted between application runs.

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 LXLogHTTPEndpoint:

init(URL: HTTPMethod: successCodes: sessionConfiguration: minimumLogLevel: 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
minimumLogLevel Type: LXLogLevel
Default: .All
The minimum Priority Level a Log Entry must meet to be accepted by this Endpoint
dateFormatter Type: NSDateFormatter
Default: default date formatter
The formatter used by this Endpoint to serialize a Log Entry’s dateTime property to a string
entryFormatter Type: LXLogEntryFormatter
Default: default Entry formatter
The formatter used by this Endpoint to serialize each Log Entry to a string

This Endpoint will upload Log Entries to the specified URL using the specified HTTPMethod. 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 may investigate supplying a customized NSURLSessionConfiguration.

Returns an initialized HTTP Endpoint instance.