The logs endpoint shows any debug logs produced by executed Functions. To have logs show up on this endpoint, add
_10console.log("This is an info level log message from my function")_10_10console.warn("This is a warning log message from my function")_10_10console.error("This is an error log message from my function")
to your Function code and invoke it. The log line will show up at the /Logs
sub-resource of an Environment. Only Environments with a deployed build will generate logs.
The Serverless Toolkit has debug log tail ability built in to aid in debugging from the command line. To tail logs for deployed functions, execute the following command from within a deployed Serverless project:
_10twilio serverless:logs --tail
Log lines written at WARN or ERROR level will also show up in the Twilio Debugger. Debugger will store WARN and ERROR logs for up to 30 days. You can set up a webhook to trigger on all (not just Functions) errors and warnings here.
For Functions created via the API, you can show live logs for debugging by loading the Services page in the Twilio Console, opening the Service to track, and clicking the Show Logs toggle in the bottom-right corner of the UI.
The Show Logs toggle will only be visible if you have a live build associated with your environment via a Deployment.
StartDate
and
EndDate
filters to limit your query.
/Logs
endpoint is rate limited to 5 requests per second.
Use these parameters on the /Logs
request to retrieve specific logs.
Name | Type |
---|---|
StartDate | ISO 8601(optional) |
EndDate | ISO 8601(optional) |
FunctionSid | sid<ZH> (optional) |
PageToken | string (optional) |
PageSize | int (default: 50) |
sid
type: SID<NO>The unique string that we created to identify the Log resource.
^NO[0-9a-fA-F]{32}$
34
34
account_sid
type: SID<AC>The SID of the Account that created the Log resource.
^AC[0-9a-fA-F]{32}$
34
34
service_sid
type: SID<ZS>The SID of the Service that the Log resource is associated with.
^ZS[0-9a-fA-F]{32}$
34
34
environment_sid
type: SID<ZE>The SID of the environment in which the log occurred.
^ZE[0-9a-fA-F]{32}$
34
34
build_sid
type: SID<ZB>The SID of the build that corresponds to the log.
^ZB[0-9a-fA-F]{32}$
34
34
deployment_sid
type: SID<ZD>The SID of the deployment that corresponds to the log.
^ZD[0-9a-fA-F]{32}$
34
34
function_sid
type: SID<ZH>The SID of the function whose invocation produced the log.
^ZH[0-9a-fA-F]{32}$
34
34
request_sid
type: SID<RQ>The SID of the request associated with the log.
^RQ[0-9a-fA-F]{32}$
34
34
level
type: enum<string>The log level. Can be: info
, warn
, or error
.
info
warn
error
date_created
type: string<date-time>The date and time in GMT when the Log resource was created specified in ISO 8601 format.
GET https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments/{EnvironmentSid}/Logs/{Sid}
EnvironmentSid
type: SID<ZE>The SID of the environment with the Log resource to fetch.
^ZE[0-9a-fA-F]{32}$
34
34
Sid
type: SID<NO>The SID of the Log resource to fetch.
^NO[0-9a-fA-F]{32}$
34
34
GET https://serverless.twilio.com/v1/Services/{ServiceSid}/Environments/{EnvironmentSid}/Logs
EnvironmentSid
type: SID<ZE>The SID of the environment with the Log resources to read.
^ZE[0-9a-fA-F]{32}$
34
34
FunctionSid
type: SID<ZH>The SID of the function whose invocation produced the Log resources to read.
^ZH[0-9a-fA-F]{32}$
34
34
StartDate
type: string<date-time>The date/time (in GMT, ISO 8601) after which the Log resources must have been created. Defaults to 1 day prior to current date/time.
EndDate
type: string<date-time>The date/time (in GMT, ISO 8601) before which the Log resources must have been created. Defaults to current date/time.
PageSize
type: integerHow many resources to return in each list page. The default is 50, and the maximum is 1000.
1
Page
type: integerThe page index. This value is simply for client state.
0