Skip to content

Commit

Permalink
Merge pull request #20045 from newrelic/NR-356329-browser-logs
Browse files Browse the repository at this point in the history
Nr 356329 browser logs
  • Loading branch information
adutta-newrelic authored Feb 24, 2025
2 parents 55e62ee + 81b611a commit 7cb618f
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,92 @@ redirects:
freshnessValidatedDate: never
---

Enhance your application's observability and debugging capabilities by following these simple setup instructions.
## Automatically detect browser logs [#automatic-log]

Auto logging collects log messages issued from the browser `console` to help you maximize observability of your front-end applications.

Browser logs are tracked by default at the `WARN` level for Pro and Pro+SPA agents, but unavailable for the Lite browser agent. We recommend that you first confirm you're using the `Pro or Pro+SPA agent`.

### How browser auto-logging works

Based on logging levels and sampling rates set in the configuration, auto-instrumentation of browser logs will attempt to collect messages from the following methods:

<table>
<thead>
<tr>
<th style={{width: "200px"}}>
Method
</th>

<th>
Level
</th>
</tr>
</thead>

<tbody>
<tr>
<td>
console.log
</td>
<td>
`INFO`
</td>
</tr>
<tr>
<td>
console.error
</td>
<td>
`ERROR`
</td>
</tr>

<tr>
<td>
console.warn
</td>
<td>
`WARN`
</td>
</tr>

<tr>
<td>
console.info
</td>
<td>
`INFO`
</td>
</tr>

<tr>
<td>
console.debug
</td>
<td>
`DEBUG`
</td>
</tr>

<tr>
<td>
console.trace
</td>
<td>
`TRACE`
</td>
</tr>
</tbody>
</table>

<Callout variant="important">
Data passed through the console methods may go through serialization and [obfuscation](/docs/browser/new-relic-browser/configuration/obfuscate-browser-agent-data). Depending on the size and frequency, this may negatively impact application performance as well as data costs. In general, it is NOT recommended to pass in large objects or large amounts of data into console methods.
</Callout>

By default, logging data is stored for 30 days, but actual data retention depends on your account.

### Prerequisites
## Prerequisites

* A **Pro** or **Pro + SPA** browser agent

Expand All @@ -19,7 +102,7 @@ Enhance your application's observability and debugging capabilities by following

## Enable automatic log collection (For Existing Browser Apps) [#enable-automatic-log]

To enable automatic log collection for an existing browser app:
Enhance your application's observability and debugging capabilities by following these simple setup instructions.

<Steps>

Expand Down Expand Up @@ -93,4 +176,10 @@ To disable browser logs for an existing browser app:
<Step>
Toggle **Browser Logs** to **OFF**.
</Step>
</Steps>
</Steps>

## Data consumption

Logs follow the same consumption pricing as your other browser bytes. The amount of bytes produced depends on the count and length of messages.

The auto logging feature eliminates the need to call the `newrelic.log` or `newrelic.wrapLogger` browser APIs, except when adding custom attributes to logging events.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The <DNT>**Browser logs**</DNT> feature offers insights into your front-end appl
<tbody>
<tr>
<td>
[**Automatic Log Collection**](/docs/browser/browser-monitoring/browser-pro-features/auto-logging)
[**Automatic Log Collection**](/docs/browser/browser-monitoring/browser-pro-features/browser-logs/get-started/#automatic-log)
</td>
<td>
Automatically captures all log messages from the browser console, including Error, Warn, Info, and Debug logs, providing a complete view of front-end activity.
Expand Down

0 comments on commit 7cb618f

Please sign in to comment.