RotatingFileHandler and logging config file
peter at engcorp.com
Sat Mar 19 18:22:38 CET 2005
Rob Cranfill wrote:
> Ah, now *there's* an intriguing approach! I am too much a Python noob to
> know - can I subclass RFH and then invoke that new class from a config
> file (the crux of my original question) ? I may play around with it
There's at least one way that will work, though it may not be
the cleanest approach.
Wherever you create your subclass, stick a reference to it in
the logging.handlers module, as "logging.handlers.MyClass = MyClass".
Then the config file can load it just as you now load the
existing class (which I assume looks like the usual examples,
The logging.cfg file is executed in the context of the logging
module's namespace, so you could also stick your names directly
in there and skip the "handlers." part, but that might be
even less clear...
More information about the Python-list