Skip to content
On this page

Online Logs

Logs can be generated through console.log in cloud functions. After the function is deployed, the logs can be viewed in the Logs tab, and can be filtered by date and keyword.

Generate and View Logs

Create a new function, e.g. log.js, and modify it as follows:

js
module.exports = async function(params, context) {
  // Print a log with current time
  console.log('Hello World. Current time is:', new Date());
  // Print a log of Error level
  console.error('This is an error');

  return {
    message: 'Hi, AirCode.',
  };
}
module.exports = async function(params, context) {
  // Print a log with current time
  console.log('Hello World. Current time is:', new Date());
  // Print a log of Error level
  console.error('This is an error');

  return {
    message: 'Hi, AirCode.',
  };
}

Deploy the function online, and click the URL below its name to copy. Open a new page in your browser and visit the URL copied above.

After that, click the Logs tab in the right area, and you can see the logs generated by online access in real-time.

Tips

There may be a few seconds delay in collecting logs, please be patient.

Log Levels

In addition to console.log, other methods can be used to generate different levels of logs, it's useful to do filtering when viewing logs.

  • console.info or console.debug: an alias method for console.log, which produces a log level of Info
  • console.error or console.warn: print the error log, and the generated log level is Error

For more usage, see: Node.js Console API.

Toggle Realtime Fetching

By default, AirCode fetches logs in real time and display them in the content area. If you want to turn off real-time fetching, you can click Pause, and the logs generated online will no longer be displayed in there.

Click the Resume button again to restart the real-time log fetching. The content area will display a starting timestamp, and the logs generated after it will be displayed in there.

Query Logs

In addition to viewing real-time logs, you can also query or filter historical logs by dimensions such as date, keyword, or log level.

Limits

In order to ensure the service is running stably, the log bandwidth and storing date will be limited, see: Resource Limits - Online Log.