This topic describes log-related commands in Function Compute Command Line Interface (fcli).
Prerequisites
In the folder where the executable file is located, run the fcli shell
command to enter the interactive mode.
Create a log project and a Logstore (mkl)
Run the mkl command to create a log project and a Logstore for Function Compute.
-p string
: creates a log project.-s string
: creates a Logstore.
>>> mkl -p my-log-project -s my-log-store myService
// Creates a log project and a Logstore for Function Compute.
// The name of a log project is globally unique. If the name has been used, the log project fails to be created.
View logs (logs)
Run the logs command to view logs.
-c int
or--count int
: sets the maximum number of returned rows of the log content. Default value: 1000.-d int
or--duration int
: specifies the duration in which function logs are returned, in seconds. Default value: 86400.-e string
or--end string
: sets the end of the time range to query. Specify the time in RFC3339 format. The time must be in UTC, for example, 2017-01-01T01:02:03Z.-s string
or--start string
: sets the beginning of the time range to query. Specify the time in RFC3339 format. The time must be in UTC, for example, 2017-01-01T01:02:03Z.-t
or--tail
: specifies row i from the end to return the last i rows of the log content.
// In the corresponding service directory
logs myFunction //Prints the first 1,000 rows of the log content of the day by default.
logs -d 60 -c 5000 myFunction //Prints the log content for function execution within 1 minute. A maximum of 5,000 rows of the log content can be returned.
logs -t -c 100 myFunction //Prints the last 100 rows of the log content.
logs -s 2018-01-22T18:00:00Z -e 2018-01-22T19:00:00Z myFunction //Prints the log content generated from 2018-01-22T18:00:00Z to 2018-01-22T19:00:00Z.