171 days ago · 9 min read1754 words · Tech · hide · Fediverse post

I’ve been working on a Python project recently. It uses the popular Flask framework to provide web services. Flask is powerful and easy to use. Although it provides application logging out of the box I wanted something a little different: a dedicated log for the web requests. My requirements are: The log is in Combined Log Format (more in a sec). The log file is called access.log. The log file rolls nightly, to a file called access.log.YYYY-MM-DD. The log records client information correctly – even when it is behind a proxy. (That last item is foreshadowing …) I’ll create a simple Python web app using Flask, and then walk through the steps to add the logging I want. But first, let’s talk about log formats. Combined Log Format I want to use Combined Log Format because there is a lot of tooling, such as log analyzers, built around this format. But first, let’s discuss its sibling, Common Log Format. This format was introduced in the venerable Apache web server, and is documented here.…

Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town