SCF CLI can be accessed through scf logs
Command to view the history or real-time logs generated by cloud functions.
scf logs
The parameters supported by the command are as follows:
Parameters | Abbreviated | Required | Description | Example |
---|---|---|---|---|
Name | -n | Yes | Gets the log of the specified function | -n testproject |
Namespace | -ns | No | Specify the namespace where the function resides | -ns test-ns |
Region | None | No | Specify the area where the function is located | -- region ap-shanghai |
Start-time | S | No | Gets the log after the specified start time | -s "2019 Mak 7 mi 12 00:00:00" |
End-time | -e | No | Gets the log before the specified start time | -e "2019Mui 7 MFI 12 00:10:00" |
Fail | -f | No | Get the log of the call failure | - |
Tail | -t | No | Get the latest real-time log | - |
Duration | -d | No | Get the log of the last x seconds | -d 600 |
Count | -c | No | Get x logs | -c 1 |
The maximum number of rows pulled from the log is 10000 lines.
For example, initialization is configured as the ap-shanghai region, and the testproject function has been run under the default namespace.
$ scf logs -n testproject
2019-07-17 11:16:39
START RequestId: 4af1a378-a841-11e9-95cb-525400e8849e
Event RequestId: 4af1a378-a841-11e9-95cb-525400e8849e
{'key2': 'test value 2', 'key1': 'test value 1'}
- Without
--duration
Parameter, the log of the most recent 1min is obtained by default.- Without
--region
Parameter, which defaults to region in scf configure.- Without
--namespace
Parameter, which defaults to the default namespace.
$ scf logs -n testproject --region ap-shanghai -ns default
2019-07-17 11:16:39
START RequestId: 4af1a378-a841-11e9-95cb-525400e8849e
Event RequestId: 4af1a378-a841-11e9-95cb-525400e8849e
{'key2': 'test value 2', 'key1': 'test value 1'}
$ scf logs -n testproject -d 600
2019-07-17 11:16:39
START RequestId: 4af1a378-a841-11e9-95cb-525400e8849e
Event RequestId: 4af1a378-a841-11e9-95cb-525400e8849e
{'key2': 'test value 2', 'key1': 'test value 1'}
$scf logs-n testproject-t2019Muz 07Mube 17 11:42:52START RequestId: f4739afa-a844-11e9-91a1-525400681fe1Event RequestId: f4739afa-a844-11e9-91a1-525400681fe1 {'Key2':'Test value 2','Key1':'Test value 1'}
END RequestId: f4739afa-a844-11e9-91a1-525400681fe1Report RequestId: f4739afa-a844-11e9-91a1-525400681fe1 Duration:0ms Memory:128MB MaxMemoryUsed:0.062500MB
Specifies that the start and end time of the function is within one day.
$scf logs-n testproject-s "20119 Mui 7 Mui 17 11:20:00"-e "2019 Mui 7 Mui 17 11:30:00" 2019 Mui 07 Mui 17 11:20:10START RequestId: c86f1057-a841-11e9-a24c-525400b2c41bEvent RequestId: c86f1057-a841-11e9-a24c-525400b2c41b {'Key2':'Test value 2','Key1':'Test value 1'}
END RequestId: c86f1057-a841-11e9-a24c-525400b2c41bReport RequestId: c86f1057-a841-11e9-a24c-525400b2c41b Duration:0ms Memory:128MB MaxMemoryUsed:0.050781MB2019-07-17 11:20:14START RequestId: cb118078-a841-11e9-95cb-525400e8849eEvent RequestId: cb118078-a841-11e9-95cb-525400e8849e {'Key2':'Test value 2','Key1':'Test value 1'}
$scf logs-n testproject-f2019 Muhami 07Muhami 17 11:47:38START RequestId: 9f15534d-a845-11e9-95cc-525400e8849eEvent RequestId: 9f15534d-a845-11e9-95cc-525400e8849e
END RequestId: 9f15534d-a845-11e9-95cc-525400e8849eReport RequestId: 9f15534d-a845-11e9-95cc-525400e8849e Duration:0ms Memory:128MB
MaxMemoryUsed:0.148438MB
Was this page helpful?