The LXFileEndpoint writes Log Entries to a specified file.

The File 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 File 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.



The following initializers are available for LXFileEndpoint:

init?(fileURL: shouldAppend: minimumPriorityLevel: dateFormatter: entryFormatter: )


fileURL Type: NSURL?
Default: see below
The file to write Log Entries to
shouldAppend Type: Bool
Default: true
Indicates whether the Endpoint should continue appending Log Entries to the end of the file, or clear it and start at the beginning
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 Endpoint writes Log Entries to the file specified by fileURL. If the specified file cannot be opened, or if the URL evaluates to nil, the initializer may fail.

If omitted, the URL defaults to {AppSupport}/{bundleID}/logs/log.txt, where {AppSupport} is the system-determined Application Support directory, and {bundleID} is the host application’s bundleIdentifier string.

Returns an initialized File Endpoint instance if successful, or nil if the file cannot be opened.