Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在 django (>=1.3) 中获取日志处理程序对象实例?使用标准 python 日志记录,我实例化记录器,然后实例化处理程序:
h = logging.handlers.TimedRotatingFileHandler( FILE, 'D', 1)
我想要h或者h当我LOGGING在settings.py. 有任何想法吗?
h
LOGGING
settings.py
我能够通过以下方式获得所有活动处理程序:
import logging h = [] for a in logging.root.handlers: h.append( a.stream )
(在上面我想要文件对象而不是实际的处理程序本身)
希望这对某人有帮助!