OK, I got TransLogger in Paste r6236 to work by placing it after
httpexceptions/ErrorHandler/ErrorDocument in middleware.py, so it
needs a special location.

I'm also using this subclass to not log requests starting with
"/error", and to drop the user agent from the log:

===
from paste.translogger import TransLogger as _TransLogger

class TransLogger(_TransLogger):
    format = ('%(REMOTE_ADDR)s - %(REMOTE_USER)s [%(time)s] '
              '"%(REQUEST_METHOD)s %(REQUEST_URI)s %(HTTP_VERSION)s" '
              '%(status)s %(bytes)s "%(HTTP_REFERER)s"')

    def __init__(self, application, **kw):
        self.ignore_url_prefixes = kw.pop("ignore_url_prefixes", [])
        _TransLogger.__init__(self, application, **kw)

    def write_log(self, environ, req_uri, start, status, bytes):
        for prefix in self.ignore_url_prefixes:
            if req_uri.startswith(prefix):
                return
        _TransLogger.write_log(self, environ, req_uri, start, status, bytes)
===

Usage in Pylons myapp/config/middleware.py:

    # Logging must be below httpexceptions/ErrorHandler/ErrorDocument or you
    # won't get the original requested URL and actual status.

app = TransLogger(app, setup_console_handler=True,
        ignore_url_prefixes=["/error"])

-- 
Mike Orr <[EMAIL PROTECTED]>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to