Logging text into a file_name.log file

How to write text input to a filename.log file in streamlit. below is my function to create a log file but it’s not working . streamlit is not able to create the log file

def Log_Data(self,data,file_name):
yield self.env.timeout(0)
# Create and configure logger
logging.basicConfig(filename=file_name,format=β€˜%(asctime)s %(message)s’,filemode=β€˜w’)
# Creating an object
logger = logging.getLogger()
# Setting the threshold of logger to DEBUG
#logging the data