AtatusLogs, so adding it does not change what RUM collects.
Prerequisites
- RUM is set up in your application, or at minimum the SDK is initialized. See iOS Monitoring Setup.
- The
AtatusLogsproduct is added to your target.
Setup
1. Add the product
With Swift Package Manager, add theAtatusLogs product to your target. With CocoaPods, declare the pod:
2. Enable logging
Enable the product once, right afterAtatus.initialize():
3. Create a logger
A logger carries the configuration for the logs it sends. Create one per area of your application, or one for the whole application:4. Send logs
Six levels are available, from least to most severe:debug, info, notice, warn, error, and critical. Each takes a message, an optional Error, and optional attributes:
Error records its type, message, and stack trace as error.kind, error.message, and error.stack on the log.
Log uploads start once Atatus confirms that logging is enabled for your account, which the SDK checks shortly after launch. Logs written before that confirmation are held on disk, not lost, so expect a short delay on the first run. Logs stay disabled if log collection is turned off for the application in your Atatus account.
Logger configuration
Every option onLogger.Configuration:
Two options are worth calling out:
remoteLogThresholdfilters what reaches Atatus, not what reaches the console. Console printing ignores the threshold.consoleLogFormataccepts.shortor.shortWith(prefix: "[MyApp] "). Console output carries the message only, so attributes and tags do not appear there.
Add attributes and tags
Attributes are key and value pairs you filter and group by. Tags are flat labels. Attach an attribute to every log from one logger:removeTag(withKey:) removes every tag with that key, not just one value. Tag keys must start with a lowercase letter, and characters outside letters, digits, _, -, :, ., and / are replaced with an underscore. A log carries at most 100 tags and 256 attributes.host, message, status, service, source, application_id, session_id, view.id, user_action.id, and build_id. The reserved tag keys are host, device, source, service, and env.
Correlate logs with RUM and traces
Correlation is on by default, so there is nothing to configure in the common case:- With
bundleWithRumEnabled, each log carries the RUM application, session, view, and action that was active when it was written. You can open a session in the dashboard and read its logs in order. - With
bundleWithTraceEnabled, a log written inside an active span carries that trace and span, so logs line up with the trace timeline. See Trace Collection.
Logs at
error and critical are also reported as RUM errors, with the source logger. This is not configurable, so expect one logger.error(...) call to appear twice in the dashboard: once in Logs and once in Error Tracking. Use warn for conditions you do not want surfaced as errors.Group errors with a fingerprint
Errors are grouped by their stack trace and message. When that grouping is wrong, for example when a message embeds an order ID, set your own fingerprint:Error.
Redact or drop logs before they are sent
An event mapper runs on every log before it leaves the device. Use it to strip sensitive data, or returnnil to drop the log entirely:
Objective-C
The logging API is available to Objective-C through the same module, withAT-prefixed types:
printLogsToConsole, which prints in the short format, and the error: parameter takes an NSError rather than any error type.
Platform support
Logging behaves the same on iOS, iPadOS, and tvOS.Next steps
- Report crashes and custom errors with Error Tracking.
- Connect logs to backend traces with Trace Collection.
- Review the RUM options in Configuration Options.