Log timestamps/durations of deployment steps?

Is there a way to get the sls deploy command to output timestamps of its progress? I want to know what the slow part of my deployment is, but I’ve not got enough information.

When running the command interactively, theres a timer that says how long it has been running. But there’s no way to determine after the fact how long it took to download/install dependencies, build the Lambda layer, compile the template, and then wait for CloudFormation to say that it completed.

And is the solution any different when using a Serverless Compose file?

I can use --verbose but that just logs more lines without any timestamps.

Thanks.

1 Like

To get timestamps for the sls deploy command, you can pipe its output through a tool that adds timestamps, such as ts from moreutils. Example:

bash

sls deploy | ts ‘[%Y-%m-%d %H:%M:%S]’

This adds a timestamp to each line of the output.

For finer granularity (e.g., stages like dependency installation or build times), you can:

  1. Use the --verbose flag and pair it with the timestamping tool.
  2. Manually add custom logging with timestamps in your serverless.yml hooks for specific stages (e.g., before:deploy:createDeploymentArtifacts).

I’ve been using the ts approach since not long after the post. But given that it’s logging and most logging uses a framework (not just “print”) and frameworks normally have a way of handling timestamps then I was hoping for something integrated.

Is there any documentation on adding logging to hooks? Because all I’m finding so far is a “Serverless Hooks” plugin, whereas you made it sound like it’s an existing feature.