Skip to content

Commit

Permalink
Merge pull request #19356 from mbruin-NR/NR-334798
Browse files Browse the repository at this point in the history
NR-334798 Created docs that explain the new auto collected logs in the iOS agent (December 3rd)
  • Loading branch information
cbehera-newrelic authored Dec 4, 2024
2 parents 70d7ba7 + 96c53ea commit add1bbe
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
title: Logging with the iOS agent
tags:
- Mobile logging
- New Relic Mobile iOS
metaDescription: Suggestions for setting up the logging in your app with the New Relic agent
freshnessValidatedDate: never
---


To ensure consistent and comprehensive logging throughout the project, the iOS agent provides logging APIs. Use the agent's logging APIs to send your mobile apps logs to New Relic. This ensures that your logs are at one place for your analysis. For more information, refer our [mobile logging API](/docs/mobile-monitoring/mobile-monitoring-ui/mobile-logs/#ios).


## Configuring log levels

You can configure the iOS agent log levels for the agent and remote logging.

### Agent Log Level

The agent log level is configured in the New Relic agent and determines which log messages are written to the device's console. This also includes the New Relic agent logs. To view all New Relic agent logs, set the log level to `NRLogLevelDebug`.


### Remote Log Level

In the New Relic platform, the remote log level controls the verbosity of logs sent from a device to New Relic. This helps to manage the data volume and keeps the focus on relevant information.

**Configuration**: On the New Relic dashboard, you can set up the remote log level in <DNT>**Application**</DNT> tab. For more information on setting the remote log level, refer [mobile logs](/docs/mobile-monitoring/mobile-monitoring-ui/mobile-logs).



## Automatic log collection

In the New Relic platform, when the remote logging is enabled, the iOS agent collects all logs written on `stdout` and `stderr` from the app. It captures all calls to `NSLog()`, Swift `print()`, and other print-family functions. The logs collected this way are set to `NRLogLevelInfo`. This feature is disabled by default. To enable it, use the `NRFeatureFlag_AutoCollectLogs` feature flag.

The agent separates log messages using a `'\n\n'` delimiter. The timestamp reflects when the agent collected the log, not when the application wrote it. This might cause difference of milliseconds as the log message was buffered before being collected by the agent.

<Callout variant="important">
This feature interferes with Xcode's built-in console, so it can not be enabled while the debugger is attached.
</Callout>

Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,39 @@ NewRelic.enableFeatures([NRMAFeatureFlags.NRFeatureFlag_BackgroundReporting])
</tr>
</tbody>
</table>

## Automatic log collection [#ios-log-collection]

<table>
<thead>
<tr>
<th style={{ width: "800px" }}>
Description
</th>

<th>
Example
</th>
</tr>
</thead>

<tbody>
<tr>
<td>
Enable or disable the collection of `stdout` & `stderr` for remote logging.
</td>

<td>
Log collection is disabled by default. To enable it, add the following feature flag:

```swift
NewRelic.disableFeatures([NRMAFeatureFlags.NRFeatureFlag_AutoCollectLogs])
```
For more information, see [iOS agent logging](/docs/mobile-monitoring/new-relic-mobile-ios/configuration/ios-remote-logging).
</td>
</tr>
</tbody>
</table>
</TabsPageItem>

<TabsPageItem id="capacitor">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
subject: iOS agent
releaseDate: '2024-12-04'
version: 7.5.3
downloadLink: 'https://download.newrelic.com/ios_agent/NewRelic_XCFramework_Agent_7.5.3.zip'
---

## Fixed in this release
* The tracked headers set in [addHTTPHeaderTrackingFor](/docs/mobile-monitoring/new-relic-mobile/mobile-sdk/add-tracked-headers) are now correctly added to network request events manually captured using [noticeNetworkRequestForURL](/docs/mobile-monitoring/new-relic-mobile/mobile-sdk/network-request-success).
* Fixed a bug in the new event system that prevented adding an attribute with a key that contain a reserved key string as a prefix.
* Made changes to address the `NRMA__deallocInteractionHistoryList` crash reported by users.

## Other notes
* The iOS agent now supports automatic log collection for remote logging. This feature is limited to `NSLog()`, Swift `print()`, and other print-family functions. To enable it, use the `NRFeatureFlag_AutoCollectLogs` feature flag. For more information on how to enable and configure remote logging, visit our [documentation](/docs/mobile-monitoring/new-relic-mobile-ios/configuration/ios-remote-logging).
* Changed the agent to agent to consistently send the sampled flag as '01' (true) in the W3C Traceparent header to maintain trace continuity with OpenTelemetry agents, which expect '00' (false) for dropped spans and '01' (true) for sampled spans.

## Support statement

* As of iOS agent version 7.4.1, the iOS agent will consolidate previously separate XCFramework and tvOS agents into a singular iOS agent.
* As of this release, the oldest supported version of the [XCFramework](/docs/release-notes/mobile-release-notes/ios-release-notes/xcframework-agent-736) is 7.3.6.
4 changes: 4 additions & 0 deletions src/nav/mobile-monitoring.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ pages:
pages:
- title: iOS config and feature flags
path: /docs/mobile-monitoring/new-relic-mobile-ios/api-guides/ios-agent-configuration-feature-flags
- title: iOS Logging
path: /docs/mobile-monitoring/new-relic-mobile-ios/configuration/ios-remote-logging
- title: iOS/tvOS crash reporting
path: /docs/mobile-monitoring/new-relic-mobile-ios/configuration/ios-tvos-crash-reporting
- title: Enable Swift interaction traces
Expand Down Expand Up @@ -240,6 +242,8 @@ pages:
path: /docs/mobile-monitoring/new-relic-mobile/mobile-sdk/network-request-failures
- title: Track HTTP requests headers
path: /docs/mobile-monitoring/new-relic-mobile/mobile-sdk/add-tracked-headers
- title: Logs page
path: /docs/mobile-monitoring/mobile-monitoring-ui/mobile-logs
- title: Best practices
path: /docs/new-relic-solutions/best-practices-guides/full-stack-observability/mobile-monitoring-best-practices-guide
- title: Overview of app launch times
Expand Down

0 comments on commit add1bbe

Please sign in to comment.