Dated File Endpoint
The LXLogDatedFileEndpoint
writes Log Entries to a selected file. At initialization time, the specified file’s name is prepended with a datestamp.
The Dated 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 Dated 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 LXLogDatedFileEndpoint
:
Parameters
fileURL |
Type: NSURL? Required |
The URL used to build the date files’ URLs; see description below |
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 a series of files specified by fileURL
, with each file’s name automatically prepended with a UTC datestamp in the format yyyy-MM-dd
. If the specified file cannot be opened, or if the datestamp-prepended URL evaluates to nil
, the initializer may fail.
As an example, if an LXLogDatedFileEndpoint
is initialized with its default parameter values and a fileURL
of Application Support/{bundleID}/logs/log.txt
, and today’s date is October 5, 2015, it will create a file in Application Support/{bundleID}/logs/
named 2015-10-05_log.txt
.
Returns an initialized Dated 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 dated log file, specified as {AppSupport}/{bundleID}/logs/{datestamp}_log.txt
where {AppSupport}
is the system-determined Application Support directory, {bundleID}
is the host application’s bundleIdentifier
string, and {datestamp}
is the current UTC date in the format yyyy-MM-dd
. If the file cannot be opened, or if the datestamp-prepended URL evaluates to nil
, the initializer may fail.
As an example, if an LXLogDatedFileEndpoint
is initialized with its default parameter values and today’s date is October 5, 2015, it will create a file in Application Support/{bundleID}/logs/
named 2015-10-05_log.txt
.
Returns an initialized Dated File Endpoint instance if successful, or nil
if the file cannot be opened.