logging and daemons
vinay_sajip at yahoo.co.uk
Mon Feb 16 18:14:08 CET 2009
On Feb 16, 1:15 pm, "Fernando M. Maresca" <fmare... at gmail.com> wrote:
> Yes, but I'm trying to use *TimedRotating*FileHandler, which makes the
> fd of the logfile change in every rotation of the logfile. So the direct
> approach of std[out|err] redirection to the logfile fd obtained from
> the logger instance is unusable (it works fine with a simple file
That's fine with a FileHandler, as long as you don't use e.g.
logrotate - that would cause the fd to change, too.
> I'm looking into this because I really need rotating, because when
> debugging is on, large amounts of data are logged, and because I like
> the logging module approach in every aspect.
You can capture the stuff written to std[out|err] using any file-like
object, so there are other options beyond redirecting to the fd of the
handler's fd or adding a write method to the logger. For example, if
you create a simple class which duck-types the file-like object, you
could create two instances, for stdout and stderr, and wire them into
sys. At any point you choose, you can choose to forward the
information collected to the log. Is all your stuff pure Python, or do
you have C extensions or subprocesses which are C-based? Also, I
assume you have a separate rotating log file per daemon - is that
More information about the Python-list