At my current project there are thousand of code lines which looks like this:

logging.info("bla-bla-bla")

I don't want to change all these lines, but I would change log behavior. My idea is changing root logger to other Experimental logger, which is configured by ini-file:

[loggers]
keys =  Experimental

[formatter_detailed]
format = %(asctime)s:%(name)s:%(levelname)s %(module)s:%(lineno)d:  %(message)s

[handler_logfile]
class = FileHandler
args = ('experimental.log', 'a')
formatter = detailed

[logger_Experimental]
level = DEBUG
qualname = Experimental
handlers = logfile
propagate = 0

Now setting the new root logger is done by this piece of code:

logging.config.fileConfig(path_to_logger_config)
logging.root = logging.getLogger('Experimental')

Is redefining of root logger safe? Maybe there is more convenient way?

I've tried to use google and looked through stackoverflow questions, but I didn't find the answer.

Edit
Report