mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
Logs
This plugin returns the CloudWatch logs of a lambda function. You can simply run serverless logs -f hello to test it out.
Logs Options
The logs plugin only requires the function name you want to fetch the logs for. Other than that there are other options that you can add for extra control. Here's the full options list:
--functionor-tThe function you want to fetch the logs for. Required--stageor-sThe stage you want to view the function logs for. If not provided, the plugin will use the default stage listed inserverless.yml. If that doesn't exist either it'll just fetch the logs from thedevstage.--regionor-rThe region you want to view the function logs for. If not provided, the plugin will use the default region listed inserverless.yml. If that doesn't exist either it'll just fetch the logs from theus-east-1region.--startTimeA specific unit in time to start fetching logs from. You can use standard date/time (ie:2010-10-20or1469705761), or simply a "since string" like30m(30 minutes),2h(2 hours),3d(3 days) and so on. We'll just fetch the logs that happened since then.--filterYou can specify a filter string to filter the log output. This is useful if you want to to get theerrorlogs for example.--tailor-tYou can optionally tail the logs and keep listening for new logs in your terminal session by passing this option.--intervalor-iIf you choose to tail the output, you can control the interval at which the framework polls the logs with this option. The default is1000ms.
Examples
serverless logs -f hello --startTime 5h
This will fetch the logs that happened in the past 5 hours.
serverless logs -f hello --startTime 1469694264
This will fetch the logs that happened starting at epoch 1469694264.
serverless logs -f hello -t
This will keep the terminal session listening for logs and display them as they happen.
serverless logs -f hello --filter serverless
This will fetch only the logs that contain the string serverless