title: How to Customize the time format for Python logging?
body: <p>I am new to Python's logging package and plan to use it for my project. I would like to customize the time format to my taste. Here is a short code I copied from a tutorial:</p>
  
  <pre><code>import logging
  
  # create logger
  logger = logging.getLogger("logging_tryout2")
  logger.setLevel(logging.DEBUG)
  
  # create console handler and set level to debug
  ch = logging.StreamHandler()
  ch.setLevel(logging.DEBUG)
  
  # create formatter
  formatter = logging.Formatter("%(asctime)s;%(levelname)s;%(message)s")
  
  # add formatter to ch
  ch.setFormatter(formatter)
  
  # add ch to logger
  logger.addHandler(ch)
  
  # "application" code
  logger.debug("debug message")
  logger.info("info message")
  logger.warn("warn message")
  logger.error("error message")
  logger.critical("critical message")
  </code></pre>
  
  <p>And here is the output:</p>
  
  <pre><code>2010-07-10 10:46:28,811;DEBUG;debug message
  2010-07-10 10:46:28,812;INFO;info message
  2010-07-10 10:46:28,812;WARNING;warn message
  2010-07-10 10:46:28,812;ERROR;error message
  2010-07-10 10:46:28,813;CRITICAL;critical message
  </code></pre>
  
  <p>I would like to shorten the time format to just: '<code>2010-07-10 10:46:28</code>', dropping the mili-second suffix. I looked at the Formatter.formatTime, but confused. I appreciate your help to achieve my goal. Thank you.</p>