I am trying to create a log config file that will create one complete log per day, but at the moment it creates multiple files;
ie.
readings.log.2013-06-17_01
readings.log.2013-06-17_02
readings.log.2013-06-17_03
readings.log.2013-06-17_04
readings.log.2013-06-17_05
readings.log.2013-06-17_06
readings.log.2013-06-18_01
readings.log.2013-06-18_02
readings.log.2013-06-18_03
readings.log.2013-06-18_04
readings.log.2013-06-18_05
readings.log.2013-06-18_06
...etc
I'm sure I have missed something, but what do I need to change in my logging config file to make it create just one complete logfile PER day, regardless of size!>?
Using Python 2.7 atm and the script runs 24/7
Thx Matt.
My Logging config file; (logging_v3.cfg)
[loggers]
keys=root
[logger_root]
handlers=screen,file
level=NOTSET
[formatters]
keys=simple,complex,logtemps
[formatter_simple]
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
[formatter_complex]
format=%(asctime)s - %(name)s - %(levelname)s - %(module)s : %(lineno)d - %(message)s
[formatter_logtemps]
format=%(asctime)s %(name)s %(levelname)s %(message)s
[handlers]
keys=file,screen
[handler_file]
class=handlers.TimedRotatingFileHandler
interval=midnight
backupCount=0
formatter=logtemps
level=INFO
args=('logs/readings.log',)
[handler_screen]
class=StreamHandler
formatter=simple
level=DEBUG
args=(sys.stdout,)
And the code I have in my program to make the above work; (obviously there is a lot more but this is the main part for the logging)
import logging
import logging.config
logging.config.fileConfig('config/logging_v3.cfg') #logfile config
logging.debug("DEBUG MODE")
logging.debug("INFO MODE")
args=('logs/readings.log',)toargs=('logs/readings.log','midnight',)- that looks like it'll pass the interval parameter as expected; I'm not sure what keys you can use in the logging config files, and it doesn't seem to be clearly documented as far as I can tell?args=('logs/readings.log', 'midnight', 'backupCount=0')or something similar.