MODPYTHON Sample Site Logging

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""
Django/MOD_PYTHON Site Logger

This module allows a Django/MOD_PYTHON server to log to the
current Apache virtual host.

Use the logging module as usual. Then add the log_extras()
function for the current request.

EXAMPLE

import logging
from site_logging import log_extras

logging.error(e.message, extra=log_extras(request))

"""
import logging
from modpython_logging import ApacheLogHandler, log_extras

"""
Define a Handler which writes WARNING messages or higher
to the Apache error_log.
"""
handler = ApacheLogHandler()
handler.setLevel(logging.WARNING)

formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
handler.setFormatter(formatter)

"""
Add the Apache log handler to logging.
"""
logging.getLogger('').addHandler(handler)

More like this

  1. Logging solution for mod_python/FCGI by mikeivanov 6 years, 7 months ago
  2. Twisted protocol for receiving logging module messages over a socket by afternoon 5 years, 6 months ago
  3. SQL Log To Console Middleware by davepeck 4 years, 8 months ago
  4. Logging Middleware by Magus 6 years, 6 months ago
  5. SQL Log Middleware - with multiple databases by guglielmocelata 3 years, 2 months ago

Comments

(Forgotten your password?)