browserログを自動検出
自動ログは、 browser console から発行されたログメッセージを収集し、フロントエンド アプリケーションの監視性を最大化するのに役立ちます。
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 browser agent.
重要
Certain settings, such as enabling or disabling browser log collection and adjusting sample rates or log verbosity, are server-side configurations. Once you add the agent snippet to your pages, you don't need to redeploy the script to change these settings. However, server-side configurations have no effect if the feature aren't included in the deployed script. This applies to browser agent version 1.259.0 or later.
browser自動ログの仕組み
browserログの自動インストゥルメンテーションは、設定で設定されたログレベルとサンプリングレートに基づいて、次の方法でメッセージの収集を試みます。
方法 | レベル |
|---|---|
console.log |
|
console.error |
|
console.warn |
|
console.info |
|
console.debug |
|
console.trace |
|
デフォルトでは、ログデータは 30 日間保存されますが、実際のデータ保持期間はアカウントによって異なります。
前提条件
A Pro or Pro + SPA browser agent:
エージェントバージョン
設定動作
1.283.0 - 1.305.0アプリケーション設定はコンソールと手動ログの両方に適用されます
1.306.0以降コンソールログと手動ログには、詳細度、サンプリング、有効化/無効化コントロールの個別の設定があります。
重要
自動ログ検出は、Lite Browser エージェントでは利用できません。
自動ログ収集を有効にする(既存のブラウザアプリの場合)
これらの簡単なセットアップ手順に従って、アプリケーションの監視機能とデバッグ機能を強化します。
one.newrelic.com > All Capabilities > Browserに移動します。
ブラウザ アプリを選択します。
左側のメニューで、 Application settings [アプリケーション設定] をクリックします。
Ensure the Pro or Pro + SPA browser agent is selected.
Toggle Automatically collect console logs to ON to collect messages sent to the browser's console.
Toggle Collect logs manually to ON to collect logs sent programatically via newrelic.log() or newrelic.wrapLogger().
サンプリング レートを編集して、ログを収集するユーザー セッションの割合を指定します。0 から 100 までの値を入力できます。
重要
ブラウザ ログのデフォルトのサンプリング レートは、ユーザー セッションの 100% に設定されています。このセッションのサンプリング レートは、 0%から100%の間の任意の値に設定できます。たとえば、セッションのサンプリング レートを50%に設定すると、ランダムに選択されたユーザー セッションの約半数からログイベントが収集されます。
Select the desired browser log verbosity level. The default verbosity level is set to WARN. The levels you can choose from:
ERROR- collect logs withERRORlevelWARN- collect logs withWARNorERRORlevelINFO- collect logs withINFO,WARN, orERRORlevelDEBUG- collect logs withDEBUG,INFO,WARN, orERRORlevelTRACE- collect logs withTRACE,DEBUG,INFO,WARN, orERRORlevel重要
コンソール メソッドを介して渡されるデータは、シリアル化および難読化される可能性があります。 サイズと頻度によっては、アプリケーションのパフォーマンスやデータコストに悪影響を及ぼす可能性があります。 一般に、大きなオブジェクトや大量のデータをコンソール メソッドに渡すことは推奨されません。

ブラウザログを無効にする
既存のブラウザ アプリのブラウザ ログを無効にするには:
one.newrelic.com > All Capabilities > Browserに移動します。
ブラウザ アプリを選択します。
左側のメニューで、 Application settings [アプリケーション設定] をクリックします。
Toggle Automatically collect console logs and Collect logs manually to OFF.
データ消費
ログは、他のbrowserバイトと同じ消費価格設定に従います。 生成されるバイトの量は、メッセージの数と長さによって異なります。
自動ロギング機能により、ロギングイベントにカスタムアトリビュートを追加する場合を除き、newrelic.log または newrelic.wrapLogger browser API呼び出す必要がなくなります。