File Endpoint
The LXLogFileEndpoint
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.
Usage
Initializers
The following initializers are available for LXLogFileEndpoint
:
Parameters
fileURL |
Type: NSURL? Required |
The file to write Log Entries to |
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 writes Log Entries to the file specified by fileURL
. The fileURL
argument is required. If the specified file cannot be opened, or if the URL evaluates to nil
, the initializer may fail.
Returns an initialized File Endpoint instance if successful, or nil
if the file cannot be opened.
Parameters
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 writes Log Entries to the default log file, specified as {AppSupport}/{bundleID}/logs/log.txt
where {AppSupport}
is the system-determined Application Support directory, and {bundleID}
is the host application’s bundleIdentifier
string. If the specified file cannot be opened, or if the URL evaluates to nil
, the initializer may fail.
Returns an initialized File Endpoint instance if successful, or nil
if the file cannot be opened.