Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Export Firebase Cloud Functions Logs to a file?

Is there a way to download cloud functions logs as a text file?

like image 762
Janaka Chathuranga Avatar asked Dec 17 '22 20:12

Janaka Chathuranga


2 Answers

  • Using Stackdriver logging UI, you can view your logs and click on the "Download logs" button to download you latest logs in JSON or CSV format (up to 300 logs at the moment. If you need more, consider exporting your logs).
  • Using Firebase CLI, you should be able to pipe the output of the functions:log command to a text file:firebase functions:log > logs.txt
like image 104
LundinCast Avatar answered Feb 02 '23 00:02

LundinCast


You can also use:

gcloud logging read "resource.type=cloud_function" --limit 1000 --format json > logs.json

To get the last 1000 log entries. You can also use --freshness=1d to get entries not older than one day. More info with and examples with gcloud logging read --help

like image 22
Nestor Solalinde Avatar answered Feb 02 '23 00:02

Nestor Solalinde