Closed GoogleCodeExporter closed 8 years ago
For example, when 'logging' is used without even calling logging.basicConfig()
the output is:
[Tue Mar 10 16:41:04 2009] [error] WARNING:root:This is a warning message
[Tue Mar 10 16:41:04 2009] [error] ERROR:root:This is an error message
[Tue Mar 10 16:41:04 2009] [error] CRITICAL:root:This is a critical error
message
One problem with implementing this integration is that the logging module API
is different for older versions.
Specifically, the logging.basicConfig() option takes no arguments in Python
2.3. This means wouldn't be able to
do it for older version of Python.
Original comment by Graham.Dumpleton@gmail.com
on 10 Mar 2009 at 5:46
Where basicConfig() does take arguments, then can use:
import logging
import sys
logging.basicConfig(stream=sys.__stderr__, datefmt='%a %b %e %H:%M:%S %Y',
format='[%(asctime)s] [%(levelname)s] [%(name)s] %(message)s')
This would yield:
[Tue Mar 10 17:14:36 2009] [notice] caught SIGTERM, shutting down
[Tue Mar 10 17:14:38 2009] [notice] Apache/2.2.9 (Ubuntu) mod_wsgi/3.0-TRUNK
Python/2.5.2 configured -- resuming normal operations
[Tue Mar 10 17:14:43 2009] [WARNING] [root] This is a warning message
[Tue Mar 10 17:14:43 2009] [ERROR] [root] This is an error message
[Tue Mar 10 17:14:43 2009] [CRITICAL] [root] This is a critical error message
This produced by Python logging module have uppercase log level name and have
the
name of the logger channel also displayed.
If also do:
logging.root.setLevel(logging.DEBUG)
then get higher levels of debug.
[Tue Mar 10 17:18:36 2009] [DEBUG] [root] This is a debug message
[Tue Mar 10 17:18:36 2009] [INFO] [root] This is an info message
[Tue Mar 10 17:18:36 2009] [WARNING] [root] This is a warning message
[Tue Mar 10 17:18:36 2009] [ERROR] [root] This is an error message
[Tue Mar 10 17:18:36 2009] [CRITICAL] [root] This is a critical error message
Anyway, given differences in Python versions, perhaps best not to do this and
just
document in wiki instead how to better integrate logging module with mod_wsgi.
Original comment by Graham.Dumpleton@gmail.com
on 10 Mar 2009 at 6:20
Decided not to take any action on this.
Original comment by Graham.Dumpleton@gmail.com
on 12 Mar 2009 at 5:03
Original issue reported on code.google.com by
Graham.Dumpleton@gmail.com
on 10 Mar 2009 at 4:00