Logs are generated by various components of the stack:
- The runtime (PHP, nodejs, etc.).
- The application.
These logs are aggregated in AWS CloudWatch - see Usage access instructions.
Usage / Examples
prod logs generated between two times on a specific date.
$ skpr logs prod --start '2017-10-11 9:00' --end '2017-10-11 10:30'
staging logs for the last hour.
$ skpr logs staging --start 1h
dev logs in real time.
$ skpr logs dev --follow
prod logs generated between two times today.
$ skpr logs prod --start '11:55' --end '12:05'
dev cloudfront logs generated between two relative times.
$ skpr logs dev --start 2h --end 30m --source cloudfront
Date / Time Formats
The following date/time formats are supported for the
- 30s "s" suffix denotes seconds.
- 15m "m" suffix denotes minutes.
- 2h "h" suffix denotes hours.
- 19:05: time with no date, defaults to current date (use 24 hour syntax)
- 2017-6-15: date with no time - assumes midnight of specified date
- 2017-6-15 19:05: date and time specified.
- 2019-04-26T07:46:40.795968088Z: RFC3339 with nanoseconds
TODO. Coming soon.
Applications need to output their logs to
stdout - this ensures the container orchestrator can aggregate logs and ship them to the storage backend. The Twelve-Factor App manifesto describes this succinctly:
A twelve-factor app never concerns itself with routing or storage of its output stream. It should not attempt to write to or manage logfiles. Instead, each running process writes its event stream, unbuffered, to
Drupal 8 or newer
- Enable and configure the Monolog module
- Enable the Monolog module, then configure it to log to a new Stdout stream.
- To install monolog module via composer, run:
composer require drupal/monolog:^1
In your projects
services.yml file add the following config:
parameters: monolog.channel_handlers: # Log to the stdout by default.\n default: ['stdout'] services: monolog.handler.stdout: class: Monolog\Handler\StreamHandler arguments: ['php://stdout']
Other applications which log to
stdout will log to AWS CloudWatch as well.
Examples of this might include Solr, ElasticSearch, MailHog or one of the various smaller service applications
which might be utilised.
If you're using Drupal 7, be sure to enable log_stdout and disable any other logging modules such as dblog or syslog.
$ skpr logs --help usage: skpr logs [<flags>] <environment> [<component>] Query logs for an Environments component of the stack Flags: --help Show context-sensitive help (also try --help-long and --help-man). --start="15m" --end="0" Args: <environment> Name of the Environment to query for logs [<component>] Name of the component of the stack to query
After looking through the logs, consider one of the following: