I have a flask application, which calls 2 functions from 2 different files. I've setup logging to 2 different files. However, the logging always seems to append to one file (whatever end point is hit first)
Here is the structure of the files -
- app.py
from file1 import fun1
from file2 import fun2
@app.route("/end_point1")
def data_1:
return fun1()
@app.route("/end_point2")
def data_2:
return fun2()
- file1.py
import logging
def fun1:
logging.basicConfig(filename = "file1.log")
logging.info("Logging function 1 details to to file1")
return foo
- file2.py
def fun2:
logging.basicConfig(filename = "file2.log")
logging.info("Logging function 2 details to to file2")
return bar
This logs fine (separately) when I run the individual python files - file1.py / file2.py But the logs append to just one file when I run the API.
What am I doing wrong with the logging? How can I fix it?