edit-icon download-icon

Logging

Last Updated: Mar 29, 2018

You can use the following codes in function to record logs at different levels:

  • console.log()
  • console.error()
  • console.warn()
  • console.info()

Log format

<Timestamp> <Request ID> <Log Level> <Message>

For example, when you run the following code:

  1. console.log('hello world');

The log output is:

  1. 2016-08-18T05:38:41.401Z 1234567890 verbose hello world

If you have set a Log Service logstore for the service of the function, the “hello world” log from the preceding example is collected to the configured logstore.

View logs

By using command line tool fcli, you can conveniently view the logs at service or function level. Try the following commands in fcli shell mode:

  • To view logs of a service dimension, run logs service_name.
  • To view logs of a function dimension, run logs service_name/function_name.
  • You can also view the logs generated during a certain period. Run logs --help for more information.

For more information about how to enable service/function log by using fcli, see relevant documentation.

Thank you! We've received your feedback.