<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to append date stamp to a log file created in Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-append-date-stamp-to-a-log-file-created-in/m-p/444261#M34793</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I do it like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;scriptName = sys.argv[0].split("\\")[-1][0:-3] #the script without the .py extension&amp;nbsp; 
dateTimeStamp = time.strftime('%Y%m%d%H%M%S') #in the format YYYYMMDDHHMMSS
userName = string.lower(os.environ.get("USERNAME"))
logFile = rootDir + "\\" + scriptName + "_" + userName + "_" + dateTimeStamp + ".log"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So the log file is named something like: "super_pivot_v93_csny490_20110209134455.log"&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 19:52:05 GMT</pubDate>
    <dc:creator>ChrisSnyder</dc:creator>
    <dc:date>2021-12-11T19:52:05Z</dc:date>
    <item>
      <title>How to append date stamp to a log file created in Python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-append-date-stamp-to-a-log-file-created-in/m-p/444260#M34792</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a python script which runs as a scheduled task each day, on a Windows 2008 server machine, which creates a log file.&amp;nbsp; However, I cannot get the log file to be created with a date appended to it.&amp;nbsp; Other CMD scripts use "update_logfile_%date:~10,4%%date:~7,2%%date:~4,2%.log" but this doesn't work.&amp;nbsp; I also tried "update_logfile_%Y-%m-%d.out", but that didn't work either.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ideally, I would like something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;update_logfile_2011_02_10.out&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could anyone help please?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mick&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Feb 2011 21:31:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-append-date-stamp-to-a-log-file-created-in/m-p/444260#M34792</guid>
      <dc:creator>MickClifford</dc:creator>
      <dc:date>2011-02-09T21:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to append date stamp to a log file created in Python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-append-date-stamp-to-a-log-file-created-in/m-p/444261#M34793</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I do it like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;scriptName = sys.argv[0].split("\\")[-1][0:-3] #the script without the .py extension&amp;nbsp; 
dateTimeStamp = time.strftime('%Y%m%d%H%M%S') #in the format YYYYMMDDHHMMSS
userName = string.lower(os.environ.get("USERNAME"))
logFile = rootDir + "\\" + scriptName + "_" + userName + "_" + dateTimeStamp + ".log"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So the log file is named something like: "super_pivot_v93_csny490_20110209134455.log"&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:52:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-append-date-stamp-to-a-log-file-created-in/m-p/444261#M34793</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-11T19:52:05Z</dc:date>
    </item>
  </channel>
</rss>

