I have a flask app with various routes setup.
I want to log messages to go to a different log file for each route.
Is this possible?
In the function that responds to the request on each route I have tried doing something like this (note this is just pseudo-code for sake of example):
@app.route('/routeA', methods=['POST']) def routeA(): logging.basicConfig(filename='/path/to/routeA.log')) ... @app.route('/routeB', methods=['POST']) def routeB(): logging.basicConfig(filename='/path/to/routeB.log')) ... @app.route('/routeC', methods=['POST']) def routeC(): logging.basicConfig(filename='/path/to/routeC.log')) ...
Which I would hope means that requests to routeC go to RouteC.log and similar for A and B
BUT if after starting uwsgi I hit /routeC first this seems to set up all logs to got to routeC.log such that when I then hit routes A or B their log lines also end up in the routeC.log
Similar occurs if I hit routeB or routeA first - whichever gets the first request establishes logging to that file and the other routes don't seem to be able to override that for their requests.
Is this kind of dynamic setting log file location depending on request actually possible?
If so what am I doing wrong?
I feel like I'm missing something basic here...