I've been banging my head on this one for a while. I have a Flask application that runs using Apache and mod_wsgi on RHEL 6 (so, Python 2.6, and Apache 2.2).
Anyway, I'm having this strange issue with the logging. I have the following logging class:
class Logger(object):
def get_logger(self):
return self.logger
def __init__(self, loggername):
self.logger = logging.getLogger(loggername)
self.logger.setLevel(logging.DEBUG)
syslog_handler = SysLogHandler(
address='/dev/log',
facility=SysLogHandler.LOG_LOCAL0
)
syslog_handler.setLevel(logging.DEBUG)
syslog_handler.setFormatter(logging.Formatter('%(levelname)s - %(message)s'))
email_handler = SMTPHandler(
mailhost='smtp.example.com',
fromaddr='error@example.com',
toaddrs=['admins@example.com'],
subject='Error Message')
email_handler.setLevel(logging.ERROR)
email_handler.setFormatter(logging.Formatter(
'''
Message type: %(levelname)s
Location: %(pathname)s:%(lineno)d
Module: %(module)s
Function: %(funcName)s
Time: %(asctime)s
Message:
%(message)s
'''))
self.logger.addHandler(syslog_handler)
self.logger.addHandler(email_handler)
Nothing to complicated there. In other modules, I instantiate the Logger class:
log = Logger('mymodule').get_logger()
and go on logging stuff. Everything works fine... for a while...
So, my problem is this: After a random period of time, logging just stops. The app continues to run just fine, processing requests, etc. Just no logs until I restart Apache.
Previously, I was using a RotatingFileHandler, and had the same issue. At that point, I thought to myself, "I'll just switch to using the SyslogHandler." So, I did. Same problem.
I feel like I must be hitting some sort of resource limit or something, but I can not figure out where to start looking.
I'd appreciate any insight on where to start looking for answers. Thanks, Matt