Reputation: 660
I have some loggings with a timestamp as name
logging_config.fileConfig( fname=ini_file, disable_existing_loggers=0 ) #, defaults, disable_existing_loggers)
logger = logging.getLogger("myLoggerABC")
logger.setLevel(logging.DEBUG)
Is it possible to configurate the logger that the logfile will be created with the first log-write-operation and not before.
Why? When I have no reasons to log something, I will have many empty files. That's ugly.
Upvotes: 0
Views: 85
Reputation: 99317
Use delay=True
in the handler's initialisation: see the documentation, as long as you are using Python 2.6 or later (and if not, consider updating). This defers creating/opening a file until something is actually logged.
Upvotes: 1