I have the following code
job_logger = logging.getLogger("abc")
job_handler = logging.FileHandler(filename)
job_logger.addHandler(job_handler)
print job_logger.something
I want to know the filename from the job_logger object. Any ideas?
Assuming the job_logger
object has only one handler for now.
>>> handler = job_logger.handlers[0]
>>> filename = handler.baseFilename
>>> print(filename)
'/tmp/test_logging_file'
And when there're multiple handlers, design your logic to get them all or get the very last one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With