A logging.FileHandler
is constructed with a file name, so is there any way to get the file name from the logging.FileHandler
object?
I tried dir(logging.FileHandler)
but didn't see any possible solutions.
A logging.FileHandler
is constructed with a file name, so is there any way to get the file name from the logging.FileHandler
object?
I tried dir(logging.FileHandler)
but didn't see any possible solutions.
>>> import logging
>>> fh = logging.FileHandler('/Users/defuz/test.txt')
>>> fh.baseFilename
'/Users/defuz/test.txt'
>>> fh.stream.name
'/Users/defuz/test.txt'
Please find dir(logging.FileHandler)
['__class__', '__delattr__', '__dict__', '__doc__', '__format__',
'__getattribute__', '__hash__', '__init__', '__module__', '__new__',
'__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__',
'__str__', '__subclasshook__', '__weakref__', '_name', '_open', 'acquire',
'addFilter', 'baseFilename', 'close', 'createLock', 'emit', 'encoding', 'filter',
'filters', 'flush', 'format', 'formatter', 'get_name', 'handle', 'handleError',
'level', 'lock', 'mode', 'name', 'release', 'removeFilter', 'setFormatter', 'setLevel',
'set_name', 'stream']
You have option obj.baseFilename to get the file name.
© 2022 - 2024 — McMap. All rights reserved.