tencent cloud

Feedback

Log view

Last updated: 2022-03-15 16:14:01
This document is currently invalid. Please refer to the documentation page of the product.

    SCF CLI can be accessed through scf logs Command to view the history or real-time logs generated by cloud functions.

    Parameter description

    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.

    Usage Examples

    For example, initialization is configured as the ap-shanghai region, and the testproject function has been run under the default namespace.

    • Execute the following command to get the log of the specified function.
    $ 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.
    • Execute the following command to get the log of the specified function under the specified namespace in the specified area.
    $  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'}
    • Execute the following command to get the log for the last 10 minutes of the specified function.
    $ 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'}
    • Execute the following command to get the real-time log of the specified function.
    $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
    • Gets the log for the specified function and the specified time period.

    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'}
    • Gets the log of the failure of the specified function call.
    $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
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support