0

What is the best way to log custom HTTP headers like X-Foo: bar received by CloudFront?

I haven't tried Real-time logs, but Standard access logs seem to log only the pre-defined set of fields/headers. My custom ones do not show up in there.

Currently I am thinking of leveraging CloudFront Functions for some custom logging. Is there any better (more easy/efficient) approach?

Greendrake
  • 1,391
  • 2
  • 13
  • 22

1 Answers1

1

Is there any reason you need to log this at the network edge rather than at your web server? Web server logging would seem to be a simple way to do this, if you're using a web server. If you're using S3 or similar as a source it might not be practical. Perhaps you could edit your question to give more context.

CloudFront functions can log to Cloudwatch Logs. If you need to log at the edge that seems like a reasonable option.

Tim
  • 31,888
  • 7
  • 52
  • 78
  • 1
    Edge logging is required simply because most requests _do not reach_ the source (which is indeed the purpose of the edge!). Besides, the source is S3 indeed. Good to know re cf functions->cloudwatch logs, thank you. – Greendrake May 29 '23 at 04:32