title: Why python logging module rotating day log mess up?
body: <p>I want to rotate two log files by day in python2.7, uWSGI, master/worker, multiple processes. I wrote a common logger named logger.py.</p>
  
  <pre><code>import yaml
  
  import logging, logging.config
  log_conf = yaml.load(open('logger.yaml'))
  logging.config.dictConfig(log_conf)
  
  logger = logging.getLogger('access')
  exc_logger = logging.getLogger('exception')
  </code></pre>
  
  <p>The other modules write logs like this.</p>
  
  <pre><code>from logger import logger, exc_logger
  ...
  logger.error('Req index error | err=%s', e)
  exc_logger.exception('Req index error')
  </code></pre>
  
  <p>Here is the configuration file logger.yaml.</p>
  
  <pre><code>version: 1
  disable_existing_loggers: False
  
  formatters:
      simple:
          format: '%(asctime)s | %(name)8s | %(levelname)s | %(message)s'
          datefmt: '%Y-%m-%d %H:%M:%S'
      detailed:
          format: '%(asctime)s | %(process)d | %(levelname)s | %(filename)s | %(lineno)d | %(funcName)s | %(message)s'
          datefmt: '%Y-%m-%d %H:%M:%S'
  
  handlers:
      console:
          class: logging.StreamHandler
          level: DEBUG
          formatter: detailed
          stream: ext://sys.stdout
  
      access_file_handler:
          class: logging.handlers.TimedRotatingFileHandler
          level: DEBUG
          formatter: detailed
          filename: log/access.log
          backupCount: 30
          encoding: utf8
          when: D
          interval: 1
          delay: True
  
      exception_file_handler:
          class: logging.handlers.TimedRotatingFileHandler
          level: ERROR
          formatter: detailed
          filename: log/exception.log
          backupCount: 30
          encoding: utf8
          when: D
          interval: 1
          delay: True
  
  loggers:
      access:
          level: DEBUG
          handlers: [console, access_file_handler]
          propagate: no
  
      exception:
          level: ERROR
          handlers: [console, exception_file_handler]
  </code></pre>
  
  <p>The problem is the date of the logs do not match with the date of  the file name. For example, here is the logs of access.log.2016-02-17.</p>
  
  <pre><code>2016-02-19 09:43:10 | 7065 | INFO | ...
  2016-02-19 09:43:10 | 7065 | INFO | ...
  ...
  2016-02-20 09:05:59 | 7065 | INFO | ...
  2016-02-20 09:05:59 | 7065 | INFO | ...
  ...
  </code></pre>
  
  <p>Why is that? Did I do anything wrong?</p>