title: Python logging module does not save to the filename specified?
body: <p>I need to distribute an application written in Python as an exe which will be installed in the Program Files folder of the user's computer. Since Program Files is by default write-protected, I need to save any files into the %APPDATA% folder on Windows. And I am doing that - I have the settings.ini, settings_db.db and another file created there.</p>
  
  <p>However, it seems that the logging module in Python refuses to save its log there, and instead saves it to the root directory instead. This is the code I have:</p>
  
  <pre><code>currentPath = os.environ["APPDATA"] + "\\tools\\"
  
  if not os.path.exists(currentPath):
      try:
          os.makedirs(os.environ["APPDATA"] + "\\tools\\")
          currentPath = os.environ["APPDATA"] + "\\tools\\"
      except:
          currentPath = os.getcwd()
  
  if not os.path.exists(currentPath + "ubc.log"):
      open(currentPath + "ubc.log", "w").close()
  
  print currentPath + "ubc.log"
  
  #Let's define the logging "manager" as well as logging format...
  logging.basicConfig(filename=currentPath + "ubc.log",
      format='%(asctime)-15s: %(name)-18s - %(levelname)-8s - %(module)-15s - %(funcName)-20s - %(lineno)-6d - %(message)s',
      level=logging.DEBUG)
  
  logger = logging.getLogger("gui-log")
  </code></pre>
  
  <p>The <code>print</code> statement above returns the correct result, gives me <code>C:\Users\Bogdan\AppData\Roaming\utools\ubc.log</code> . The <code>os.path.exists()</code> part successfully creates the file if one does not exist. But the logger just won't log there - it instead logs to the file in the directory from which the <code>.py</code>script has been executed. </p>
  
  <p>Not sure if it matters, but before I had the <code>filename="ubc.log"</code>, and it did log to that file, but when the need arose to distribute this application, I changed that.</p>
  
  <p>Anyone have any ideas?</p>