Changing where log files are written

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 path and timestamp_format variables on select endpoints. The logging system combines the path, timestamp_format, and uid variables to create the file name:

<path><timestamp>-<uid>.log<suffixes>

This guide explains how to use the path and timestamp_format variables to control where log files are written.

Timestamp format

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 timestamp_format variable is provided as a strftime compatible format. The default format is ISO 8601 Combined Date/Time Format:

%Y-%m-%dT%H:%M:%S.000

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 1970-01-01T00:00:00.000.

Path

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. If path ends in a trailing /, then 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 path were my_logs/, then log files would be written to the directory (or folder) my_logs. However, if the value of path were 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 path were my_logs/foo, then log files would be written to the my_logs directory and would be prefixed with the string foo.

TIP

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.

Suffixes

Fastly's logging system automatically adds suffixes to files as appropriate.

SuffixFile type
.logPlain log file
.log.gzGzipped log file
.log.gpgPGP encrypted log file
.log.gz.gpgPGP encrypted, Gzipped log file
Was this guide helpful?

Do not use this form to send sensitive information. If you need assistance, contact support. This form is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.