0

In python I wrote the configfile.properties file as following for logging:

[loggers]=
keys=root

[handlers]=
keys=fileHandler

[formatters]=
keys=myFormatter

[logger_root]=
level=INFO
handlers=fileHandler

[handler_fileHandler]=
class=FileHandler
level=INFO
formatter=myFormatter
args=("/opt/myfile1.log",)

[formatter_myFormatter]=
format=%(process)d-%(levelname)s-%(asctime)s %(name)s->%(funcName)s->%(lineno)-d: %(message)s

And i used it in a .py file as following:

import logging
import logging.config    
logging.config.fileConfig(fname='configfile.properties', disable_existing_loggers=False)
    logger = logging.getLogger(__name__)

I call multiple REST API service and then i want to store each APIs log in specific files, I need to create multi log file (/opt/myfile1.log, /opt/myfile2.log, /opt/myfile3.log) with one config file. Is there any way to create these files using that configfile.properties?

lida
  • 137
  • 1
  • 9
  • definitely, but this depends on how you actually *read* the configfile. What's the code which actually creates your logging instance? What's the issue here---creating a logging instance logging to multiple files, or storing multiple values in a config file? Why exactly do you need these multiple files (might clarify the answer) – 2e0byo Oct 06 '21 at 12:00
  • Thanks all. I updated my question that shows how to use config file for logging and clarify my question – lida Oct 06 '21 at 13:43

0 Answers0