Logging in Pulsar

59 views
Skip to first unread message

Sebastian Krause

unread,
Aug 12, 2014, 6:24:36 AM8/12/14
to python...@googlegroups.com
Hi,

I'm currently trying to customize Pulsar's logging through the "logconfig" parameter in my WSGIServer and have some questions about that:

1. How does Pulsar's logging work in a multi-process setup? If I have e.g. 4 worker processes and log everything into a file, do the worker-processes log through the master process or does each worker try to log into the file directly? In the second case I could imaging some problems on Windows because concurrent write access to the same file is usually not possible.

2. Can I let Pulsar log all HTTP requests? If not, where would I add this functionality, mabye through an additional middleware?

3. How can I route my own logging statements (in my wsgi app) through Pulsar's logging? Statements like this should show up in Pulsar's central logging:

import logging
logger = logging.getLogger(__name__)
logger.warn("Warning! Warning!")

Sebastian

Luca Sbardella

unread,
Aug 12, 2014, 7:12:08 AM8/12/14
to Sebastian Krause, python...@googlegroups.com
On 12 August 2014 11:24, Sebastian Krause <dazo...@gmail.com> wrote:
Hi,

I'm currently trying to customize Pulsar's logging through the "logconfig" parameter in my WSGIServer and have some questions about that:

1. How does Pulsar's logging work in a multi-process setup? If I have e.g. 4 worker processes and log everything into a file, do the worker-processes log through the master process or does each worker try to log into the file directly? In the second case I could imaging some problems on Windows because concurrent write access to the same file is usually not possible.

Each worker will log independently to the file. That should work fine, but I haven't test it in windows, happy to help if problems occur.
 

2. Can I let Pulsar log all HTTP requests? If not, where would I add this functionality, mabye through an additional middleware?

Pulsar wsgi server does not log each request unless errors occur. A middleware is exactly what you you need here.


3. How can I route my own logging statements (in my wsgi app) through Pulsar's logging? Statements like this should show up in Pulsar's central logging:

Pulsar does not have its own logging, but it can help you configure your logger in two ways:

The easiest and speediest way is to pass your app logger name to the --log-level command line option:

    python manage.py --log-level myapp.info

where my *myapp* is the name of your logger. Another example

 python manage.py --log-level warning myapp.info myapp2.debug

configure the *pulsar* namespace in warning mode, myapp namespace in info mode and myapp2 in debug mode.


Or via the logconfig dictionary in the config.py file.


--
Reply all
Reply to author
Forward
0 new messages