[Chicago] Taking Some Pain Out Of Python Logging

Peter Fein pete at wearpants.org
Thu Mar 7 16:13:54 CET 2013


On Thu, Mar 7, 2013 at 9:01 AM, Skip Montanaro <skip at pobox.com> wrote:
> At work we've used the stdlib logger in the platform I work on for
> quite awhile.  We log heavily, and were always disappointed in logging
> performance.  It was mostly caused by all the features baked into the
> stdlib logger which we never used (I'm sure inherited from log4j or
> whatever its logical parent was).  Over time we tried various things,
> including inlining a stripped down __init__, threading the loggers,
> rewriting things in C++, yadda, yadda, yadda.  A few months ago I
> broke down and wrote a very simple class which implements the basic
> logging API, can only log in one format, and only uses those features
> we actually need.  The platform is very mature, so I'm not worried

Code please? :-)

> (*) When you think about it, running a logger in its own thread is
> probably not that useful.  The OS probably does a much better job of
> scheduling writes to disk, and to switch threads you have to go
> through the kernel anyway. The threaded logger has more trips through
> the kernel to write to the file, once to switch to the logger thread,
> once to write the bits. Just write the damn message and be done with
> it...

In my logger Twiggy, I have support for what I call "asynchronous
logging" - use a child process to do the actual disk write.
http://twiggy.wearpants.org/

-- 
Peter Fein | wearpants.org | @wearpants

I read email at the start and end of each day. IM if urgent.


More information about the Chicago mailing list