Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NR-334798 Created docs that explain the new auto collected logs in the iOS agent (November 26th) #19356

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
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
---

## Logging Guidelines

### Overview

To ensure consistent and comprehensive logging throughout the project, the iOS agent provides logging APIs. Using the agent's logging APIs is the best way to send your mobile apps logs to New Relic. Your logs will be in one place where you can analyze them. For more information on our [mobile logging api](/docs/mobile-monitoring/mobile-monitoring-ui/mobile-logs/#ios).

## Configuring log levels

### 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 will include the logs our agent uses, to see all logs the agent uses set the log level to `NRLogLevelDebug`.

Check warning on line 19 in src/content/docs/mobile-monitoring/new-relic-mobile-ios/configuration/ios-remote-logging.mdx

View workflow job for this annotation

GitHub Actions / vale-linter

[vale] reported by reviewdog 🐶 [Microsoft.Passive] 'is configured' looks like passive voice. Raw Output: {"message": "[Microsoft.Passive] 'is configured' looks like passive voice.", "location": {"path": "src/content/docs/mobile-monitoring/new-relic-mobile-ios/configuration/ios-remote-logging.mdx", "range": {"start": {"line": 19, "column": 21}}}, "severity": "INFO"}

Check warning on line 19 in src/content/docs/mobile-monitoring/new-relic-mobile-ios/configuration/ios-remote-logging.mdx

View workflow job for this annotation

GitHub Actions / vale-linter

[vale] reported by reviewdog 🐶 [Microsoft.Passive] 'are written' looks like passive voice. Raw Output: {"message": "[Microsoft.Passive] 'are written' looks like passive voice.", "location": {"path": "src/content/docs/mobile-monitoring/new-relic-mobile-ios/configuration/ios-remote-logging.mdx", "range": {"start": {"line": 19, "column": 92}}}, "severity": "INFO"}

### Remote Log Level
The remote log level is configured in New Relic One (NR1) and determines which log messages are sent from the device to New Relic. This setting allows you to control the verbosity of logs that are transmitted and stored remotely, helping to manage data volume and focus on relevant information.

Check warning on line 22 in src/content/docs/mobile-monitoring/new-relic-mobile-ios/configuration/ios-remote-logging.mdx

View workflow job for this annotation

GitHub Actions / vale-linter

[vale] reported by reviewdog 🐶 [Microsoft.Passive] 'is configured' looks like passive voice. Raw Output: {"message": "[Microsoft.Passive] 'is configured' looks like passive voice.", "location": {"path": "src/content/docs/mobile-monitoring/new-relic-mobile-ios/configuration/ios-remote-logging.mdx", "range": {"start": {"line": 22, "column": 22}}}, "severity": "INFO"}

Check warning on line 22 in src/content/docs/mobile-monitoring/new-relic-mobile-ios/configuration/ios-remote-logging.mdx

View workflow job for this annotation

GitHub Actions / vale-linter

[vale] reported by reviewdog 🐶 [Microsoft.Passive] 'are sent' looks like passive voice. Raw Output: {"message": "[Microsoft.Passive] 'are sent' looks like passive voice.", "location": {"path": "src/content/docs/mobile-monitoring/new-relic-mobile-ios/configuration/ios-remote-logging.mdx", "range": {"start": {"line": 22, "column": 93}}}, "severity": "INFO"}

Check warning on line 22 in src/content/docs/mobile-monitoring/new-relic-mobile-ios/configuration/ios-remote-logging.mdx

View workflow job for this annotation

GitHub Actions / vale-linter

[vale] reported by reviewdog 🐶 [Microsoft.Passive] 'are transmitted' looks like passive voice. Raw Output: {"message": "[Microsoft.Passive] 'are transmitted' looks like passive voice.", "location": {"path": "src/content/docs/mobile-monitoring/new-relic-mobile-ios/configuration/ios-remote-logging.mdx", "range": {"start": {"line": 22, "column": 194}}}, "severity": "INFO"}

Configuration: The remote log level can be set in the Application tab of the New Relic One dashboard. For more information on setting the remote log level, see [mobile logs](/docs/mobile-monitoring/mobile-monitoring-ui/mobile-logs).

Check warning on line 24 in src/content/docs/mobile-monitoring/new-relic-mobile-ios/configuration/ios-remote-logging.mdx

View workflow job for this annotation

GitHub Actions / vale-linter

[vale] reported by reviewdog 🐶 [Microsoft.Passive] 'be set' looks like passive voice. Raw Output: {"message": "[Microsoft.Passive] 'be set' looks like passive voice.", "location": {"path": "src/content/docs/mobile-monitoring/new-relic-mobile-ios/configuration/ios-remote-logging.mdx", "range": {"start": {"line": 24, "column": 41}}}, "severity": "INFO"}

## Automatic log collection

If remote logging is turned on in New Relic One the iOS agent collects all logs written by the app to stdout and stderr. It captures all calls to `NSLog()`, Swift `print()`, and other print-family functions. The default level of logs collected in this way is `NRLogLevelInfo`. This feature is enabled by default and can be disabled using the `NRFeatureFlag_AutoCollectLogs` feature flag.

Check warning on line 28 in src/content/docs/mobile-monitoring/new-relic-mobile-ios/configuration/ios-remote-logging.mdx

View workflow job for this annotation

GitHub Actions / vale-linter

[vale] reported by reviewdog 🐶 [Microsoft.Passive] 'is turned' looks like passive voice. Raw Output: {"message": "[Microsoft.Passive] 'is turned' looks like passive voice.", "location": {"path": "src/content/docs/mobile-monitoring/new-relic-mobile-ios/configuration/ios-remote-logging.mdx", "range": {"start": {"line": 28, "column": 19}}}, "severity": "INFO"}

Check warning on line 28 in src/content/docs/mobile-monitoring/new-relic-mobile-ios/configuration/ios-remote-logging.mdx

View workflow job for this annotation

GitHub Actions / vale-linter

[vale] reported by reviewdog 🐶 [Microsoft.Passive] 'is enabled' looks like passive voice. Raw Output: {"message": "[Microsoft.Passive] 'is enabled' looks like passive voice.", "location": {"path": "src/content/docs/mobile-monitoring/new-relic-mobile-ios/configuration/ios-remote-logging.mdx", "range": {"start": {"line": 28, "column": 292}}}, "severity": "INFO"}

Check warning on line 28 in src/content/docs/mobile-monitoring/new-relic-mobile-ios/configuration/ios-remote-logging.mdx

View workflow job for this annotation

GitHub Actions / vale-linter

[vale] reported by reviewdog 🐶 [Microsoft.Passive] 'be disabled' looks like passive voice. Raw Output: {"message": "[Microsoft.Passive] 'be disabled' looks like passive voice.", "location": {"path": "src/content/docs/mobile-monitoring/new-relic-mobile-ios/configuration/ios-remote-logging.mdx", "range": {"start": {"line": 28, "column": 322}}}, "severity": "INFO"}
The agent uses a `'\n\n'` delimiter to separate log messages. The timestamp of the log message is the time the log was collected by the agent, not the time the log was written by the app. This might cause several milliseconds of difference because the log message was buffered before being collected by the agent.

Check warning on line 29 in src/content/docs/mobile-monitoring/new-relic-mobile-ios/configuration/ios-remote-logging.mdx

View workflow job for this annotation

GitHub Actions / vale-linter

[vale] reported by reviewdog 🐶 [Microsoft.Passive] 'was collected' looks like passive voice. Raw Output: {"message": "[Microsoft.Passive] 'was collected' looks like passive voice.", "location": {"path": "src/content/docs/mobile-monitoring/new-relic-mobile-ios/configuration/ios-remote-logging.mdx", "range": {"start": {"line": 29, "column": 116}}}, "severity": "INFO"}

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


<InstallFeedback />
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 enabled by default. To disable it, add the following feature flag:

```swift
NewRelic.enableFeatures([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
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
Loading