Logging to HTTP or File

Jorge Vargas jorge.vargas at gmail.com
Wed Feb 27 11:41:15 CET 2008


On Wed, Feb 27, 2008 at 4:16 AM, Robert Rawlins - Think Blue
<robert.rawlins at thinkbluemedia.co.uk> wrote:
>
>
>
>
> Hello Chaps,
>
>
>
> I'm after some advice on the best way to handle a logging job. Essentially I
> have data which I'm looking to log to a webservice, it would make good sense
> I think to use something like the HTTP handler for the python logging API.
>
>
>
> The problem comes when the application isn't 'online' as it were, with no
> network connection or if the webservice isn't currently available. In this
> case I don't want to simply loose all the log data, I want it stored into a
> file, I can then run hourly batch/cron tasks to upload to the service when
> the system comes back online.
>
what exactly is this webservice? if you are expecting to have issue
with it why not just store locally and run a backup utility to
duplicate your logs?
>
>
> How would you manage this? I'm thinking about building my own custom log
> handler for the task, which if unable to resolve the webservice will just
> log to the file instead, I'm just not sure if there is a better way of
> achieving this, what are your thoughts?
>
if you really need this then I guess it's the best way to "merge" both
loggers into the same class.
>
>
> In addition to this, does anyone know which libararys the HTTP handler uses
> to make its call? Is it a good one which will recognise if the system has no
> network connection or if the server is temporarily unavailable? Is it
> asynchronous?
yes httplib what else will it use?

One of the things I love about python is that you can just go poke
into your installation to see how "the api" does things.
the relevant code is in /usr/lib/python2.5/logging/handlers.py:857 for
the HTTPHandler and /usr/lib/python2.5/logging/__init__.py:759 for the
FileHandler



>
>
>
> Thanks for any advice guys,
>
>
>
> Robert
> --
>  http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list