実行ログ
Google 広告スクリプトでは、プレビュー モードと実際の実行の両方で、変更ログとログ出力の 2 種類の実行ログが表示されます。
- 変更ログ
変更ログには、スクリプトによって行われた Google 広告エンティティに対するすべての変更(エンティティの説明、変更の種類、前後の値、エラー(存在する場合))が表示されます。

変更ログにフィルタを適用して、エラーのみを表示させることも可能です。
- ログの出力
スクリプトで console.log("Hello world!");
を実行すると、ログに「Hello world!」と表示されます。テキストのビットをロギングすることは、デバッグ時に特に役立ちますが、ライブ実行時にも役立つことがよくあります。たとえば、次のスクリプトを毎日実行するようスケジュール設定しているとします。
let spreadsheet = SpreadsheetApp.create("Daily Report");
// Populate the spreadsheet.
// ...
console.log("Daily report ready!");
console.log(spreadsheet.getUrl());
スクリプトは実行のたびに、新しく作成されたスプレッドシートの URL をログに記録します。これにより、後で簡単に見つけることができます。console.warn()
または console.error()
を使用して、ログにオレンジ色または赤色のテキストを記録することもできます。
テキストログには、プログラマが指定したログ メッセージに加えて、Google 広告スクリプトの実行中に発生したエラーと警告も表示されます。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-03-04 UTC。
[null,null,["最終更新日 2025-03-04 UTC。"],[[["Google Ads scripts provide two types of execution logs: Changes logs (tracking entity modifications) and Logs output (displaying script messages)."],["Changes logs detail all alterations made by the script to Google Ads entities, including before and after values, and can be filtered to show only errors."],["Logs output displays messages generated by the script using `console.log`, `console.warn`, and `console.error`, useful for debugging and providing context during live executions."],["Errors and warnings encountered by scripts during execution are automatically included in the text logs for troubleshooting."]]],[]]