Writing and Viewing Logs

Logging is an important tool for debugging and monitoring code. Cloud Functions gives you same console object that you'd expect while developing for the web.

Writing logs

To emit a log line from your function, use either console.log or console.error.

exports.helloError = functions.https.onRequest((request, response) => {
  console.log('I am a log entry!');
  response.send('Hello World...');
});
  • console.log() commands have the INFO log level.
  • console.info() commands have the INFO log level.
  • console.warn() commands have the ERROR log level.
  • console.error() commands have the ERROR log level.
  • Internal system messages have the DEBUG log level.

Viewing logs

Logs for Cloud Functions are viewable either in the Firebase console, Stackdriver Logging UI, or via the firebase command-line tool.

Using the Firebase CLI

To view logs with the firebase tool, use the functions:log command:

firebase functions:log

To view logs for a specific function, provide the function name as an argument:

firebase functions:log --only <FUNCTION_NAME>

For the full range of log viewing options, view the help for functions:log:

firebase help functions:log

Using the Firebase Console

You can view logs for Cloud Functions from the Firebase console.

Using the Stackdriver Logging UI

You can view logs for Cloud Functions in the Stackdriver Logging UI.

Send feedback about...

Need help? Visit our support page.