title: How do you add datetime to a logfile name?
body: <p>When I create my logfile,  I want the name to contain the datetime.</p>
  <p>In Python you can get the current datetime as:</p>
  <pre><code>&gt;&gt;&gt; from datetime import datetime
  &gt;&gt;&gt; datetime.now()
  datetime.datetime(2012, 2, 3, 21, 35, 9, 559000)
  </code></pre>
  <p>The str version is</p>
  <pre><code>&gt;&gt;&gt; str(datetime.now())
  '2012-02-03 21:35:22.247000'
  </code></pre>
  <p>Not a very nice str to append to the logfile name!  I would like my logfile to be something like:</p>
  <pre><code>mylogfile_21_35_03_02_2012.log
  </code></pre>
  <p>Is there something Python can do to make this easy? I am creating the log file as:</p>
  <pre><code>fh = logging.FileHandler(&quot;mylogfile&quot; + datetimecomp + &quot;.log&quot;)
  </code></pre>