We have a nasty problem where we see that the python logging module is behaving differently when running with mod_python on our servers. When executing the same code in the shell, or in django with the runserver command or with mod_wsgi, the behavior is correct:
import logging
logger = logging.getLogger('site-errors')
logging.debug('logger=%s' % (logger.__dict__))
logging.debug('logger.parent=%s' % (logger.parent.__dict__))
logger.error('some message that is not logged.')
We then the following logging:
2009-05-28 10:36:43,740,DEBUG,error_middleware.py:31,[logger={'name': 'site-errors', 'parent': <logging.RootLogger instance at 0x85f8aac>, 'handlers': [], 'level': 0, 'disabled': 0, 'manager': <logging.Manager instance at 0x85f8aec>, 'propagate': 1, 'filters': []}]
2009-05-28 10:36:43,740,DEBUG,error_middleware.py:32,[logger.parent={'name': 'root', 'parent': None, 'handlers': [<logging.StreamHandler instance at 0x8ec612c>, <logging.handlers.RotatingFileHandler instance at 0x8ec616c>], 'level': 10, 'disabled': 0, 'propagate': 1, 'filters': []}]
As one can see, no handlers or level is set for the child logger 'site-errors'.
The logging configuration is done in the settings.py:
MONITOR_LOGGING_CONFIG = ROOT + 'error_monitor_logging.conf'
import logging
import logging.config
logging.config.fileConfig(MONITOR_LOGGING_CONFIG)
if CONFIG == CONFIG_DEV:
DB_LOGLEVEL = logging.INFO
else:
DB_LOGLEVEL = logging.WARNING
The second problem is that we also add a custom handler in the __init__.py that resides that in the folder as error_middleware.py:
import logging
from django.conf import settings
from db_log_handler import DBLogHandler
handler = DBLogHandler()
handler.setLevel(settings.DB_LOGLEVEL)
logging.root.addHandler(handler)
The custom handler cannot be seen in the logging!
If someone has idea where the problem lies, please let us know! Don't hesistate to ask for additonal information. That will certainly help to solve the problem.