简体   繁体   English

python的logging.handlers.WatchedFileHandler在哪里?

[英]Where is python's logging.handlers.WatchedFileHandler?

I'm building a project with python 2.7, and would love to have my logs rotate (managed in the usual way by logrotate ). 我正在使用python 2.7构建项目,并且希望旋转日志(以通常的方式通过logrotate )。 Python logging has a mechanism for handling this- WatchedFileHandler , however, I dont know how to install or where to find it! Python日志记录具有处理此机制的WatchedFileHandler ,但是,我不知道如何安装或在哪里找到它!

.virtualenv/bin/python -c 'import logging; print logging.__version__'
> 0.5.1.2

this seems like the most current version, however, the handlers package is no where to be found. 这似乎是最新版本,但是在哪里找不到handlers包。 Am I going crazy? 我要疯了吗?

You should not use the logging package from PyPI but just the built-in logging module: 您不应使用来自PyPI的logging包,而应使用内置的logging模块:

>>> import logging.handlers
>>> logging.handlers.WatchedFileHandler
<class 'logging.handlers.WatchedFileHandler'>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM