I have a Python logging config file that contains a RotatingFileHan dler
handler. In the args key, I have hard-coded the log filename. Everything
works great.
However, I find that I now need to override this filename at application
runtime. Is there a good way to do this?
Here is a bit of sample code that (hopefully) clarifies my question.
--------------- log.ini -----------------
[loggers]
keys=root,proce ssor
; Lots more stuff here: handlers, formatters, and loggers.......
[handlers]
keys=consoleHan dler,fileHandle r
[handler_fileHan dler]
class=handlers. RotatingFileHan dler
level=DEBUG
formatter=stand ard
args=('D:\Proje cts\Python\src\ log.log', 'a', 99999, 10)
-------------- mymain.py -----------------
import logging.config
logging.config. fileConfig('log .ini')
# TODO: Override log filename with new name (e.g. 'd:\\logs\\myma in.py.log')
log = logging.getLogg er('mymain')
log.info('START : mymain.py')
log.info('FINIS H: mymain.py')
------------------------------------------
adTHANKSvance,
Kenneth Love
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Kenneth Love | Oklahoma Tax Commission
DP Programmer/Analyst | Information Technology
(405) 522 - 5864 | http://www.tax.ok.gov/
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-