9 hours ago · Tech · 0 comments

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.…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.