I have multiple python scripts I run at the same time. They all located in the same directory. One of those is imported in another by "import". In those 2 files I have this:
script #1
log_file_name = "logs/somefile_name.log")
logging.basicConfig(filename=log_file_name)
script #2
log_file_name = "logs/somefile_name2.log")
logging.basicConfig(filename=log_file_name)
Again, script #2 is imported in script #1 because script #2 has some functions I need in the 1st one.
For some reason I see only one log file, although they have different names. Why is that? I think the settings of creating the logger get overwritten. How to fix it?
logging.basicConfig()
is ignored after the first time it is called. The root logger in the module is meant to be used as a singleton. If you want to add more log files, you need to add new handlers.