Troubleshooting logs in a parallel world
We briefly touched on logs earlier. Remember that Packer randomly colorizes logs to distinguish multiple build streams appearing in the same terminal. Now that we’re preparing to automate builds, we will need to plan to keep all logs for each build. They should be organized in a way that makes it easy to troubleshoot problems.
Logs should be archived and saved from each build. Store each log in its own directory, named with a timestamp or unique identifier that makes them easy to find. Retention policies should be established for archival, compression, and indexing of the logs, which can become quite large. This can be a simple time retention or a size retention policy. Using a size retention policy can help keep raw logs small enough that grep or file indexing can search the logs with ease:
- Logs less than 1 month old are kept raw in directories
- Logs 1 month to a year old are compressed as
tar.zstd
archives - Logs older...