Changing where log files are written
Last updated 2022-11-17
For supported logging endpoints that write files to remote services, Fastly uses a combination of factors to ensure log files aren't overwritten, including:
- Using the file creation timestamp.
- Generating a unique ID.
- If a file with the same timestamp and UID combination exists, incrementing a counter and adding that to the end of the filename.
To change where log files are written, you can modify the
timestamp_format variables on select endpoints. The logging system combines the
uid variables to create the file name:
This guide explains how to use the
timestamp_format variables to control where log files are written.
You may want to consider changing the timestamp format to remove characters from the log filenames. For example, if you're working with Elastic MapReduce, you might need to remove the colons in the filename.
The variables are expanded when the file is created. For example,
%Y will be replaced by the current year and
%m by the current month number:
<year>-<2 digit month number>-<2 digit day number>T<hour>:<minute>:<second>
The timestamp for a file created at midnight on January 1st, 1970 would be
File-based (e.g., SFTP) and object-based (e.g., S3) endpoints use the
path variable in different ways. File-based endpoints use
path to create directories and files in the logging endpoint's storage. Directories will be created automatically if possible. Object-based endpoints use
path plus the file name to create the key in an object store. No actual directories are created by object-based endpoints because they don't use directory structures in their storage.
File-based and object-based endpoints both look for
/ characters in
path ends in a trailing
path is treated as a directory by a file-based endpoint and as a folder (the logical equivalent of a directory) by an object-based endpoint. For example, if the value of
my_logs/, then log files would be written to the directory (or folder)
my_logs. However, if the value of
my_logs, without the trailing
/, then log files would be written to the top-level directory and would be prefixed with the string
my_logs. Furthermore, if the value of
my_logs/foo, then log files would be written to the
my_logs directory and would be prefixed with the string
The path can also be a
strftime compatible string. For example, if the variable is set to
%Y/%m/%d, the files are written to a directory based on the year, month, and date.
Fastly's logging system automatically adds suffixes to files as appropriate.
|.log||Plain log file|
|.log.gz||Gzipped log file|
|.log.gpg||PGP encrypted log file|
|.log.gz.gpg||PGP encrypted, Gzipped log file|