title: How stop re-writing log data during program re-run / Python
body: <p>I having an issue with logging. Every time when i re-run my program it overwrites log data in file as I need to store previous data as well. I have created if statements when there is file it doesn't create a new one as i thought, but it doesn't solved my problem. Maybe someone knows the issue? Thank you in advance!</p>
  <pre><code>from tkinter import *
  from tkinter import filedialog
  import easygui
  import shutil
  import os
  from tkinter import filedialog
  from tkinter import messagebox as mb
  from pathlib import Path
  import logging
  from datetime import date
  
  
  def open_window():
      read=easygui.fileopenbox()
      return read
  
  #logging config
  
  if Path('app.log').is_file():
      print (&quot;File exist&quot;)
  else:
      logging.basicConfig(filename='app.log', filemode=&quot;w&quot;, format='%(name)s - %(levelname)s - %(message)s ')
      print (&quot;File doesn't exist and will be created&quot;)
  
  
  LOG_for=&quot;%(asctime)s, log content: %(message)s&quot;
  
  logger=logging.getLogger()
  logger.setLevel(logging.DEBUG)
  
  
  # Function for opening the
  # file explorer window
  def browseFiles():
      filename = filedialog.askopenfilename(initialdir = &quot;/&quot;,
                                            title = &quot;Select a File&quot;,
                                            filetypes = ((&quot;Text files&quot;,
                                                          &quot;*.txt*&quot;),
                                                         (&quot;all files&quot;,
                                                          &quot;*.*&quot;)))
        
      # Change label contents
      label_file_explorer.configure(text=&quot;File Opened: &quot;+filename)
        
  # move file function
  def move_file():
      source = open_window()
      filename = os.path.basename(source)
      destination =filedialog.askdirectory()
      dest = os.path.join(destination,filename)
      if(source==dest):
          mb.showinfo('confirmation', &quot;Source and destination are same, therefore file will be moved to Home catalog&quot;)
          newdestination = Path(&quot;/home/adminas&quot;)
          shutil.move(source, newdestination)
          logging.shutdown()
          #current_time()
          logging.basicConfig(filename='app.log', filemode=&quot;w&quot;, format=LOG_for) 
          logging.info('File was moved to' + newdestination)
          
      else:
          shutil.move(source, destination)  
          mb.showinfo('confirmation', &quot;File Moved !&quot;)
          #current_time()
          logging.basicConfig(filename='app.log', filemode=&quot;w&quot;, format=LOG_for)
          logging.info('File was moved to' + destination) 
                                                                                                    
  # Create the root window
  window = Tk()
    
  # Set window title
  window.title('File Explorer')
    
  # Set window size
  window.geometry(&quot;400x400&quot;)
    
  #Set window background color
  window.config(background = &quot;white&quot;)
    
  # Create a File Explorer label
  label_file_explorer = Label(window,
                              text = &quot;File Explorer using Tkinter&quot;,
                              width = 50, height = 4,
                              fg = &quot;blue&quot;)
    
        
  button_explore = Button(window,
                          text = &quot;Browse Files&quot;,
                          command = browseFiles)
  
  button_move = Button(window,
                          text = &quot;Move File&quot;,
                          command = move_file)     
    
  button_exit = Button(window,
                       text = &quot;Exit&quot;,
                       command = exit)
    
  # Grid method is chosen for placing
  # the widgets at respective positions
  # in a table like structure by
  # specifying rows and columns
  label_file_explorer.grid(column = 1, row = 1)
  
  button_move.grid(column = 1, row = 2)
    
  button_exit.grid(column = 1,row = 3)
    
  # Let the window wait for any events
  logging.shutdown()
  window.mainloop()
  </code></pre>
  <p>But in the shell it prints properly, but every time running program over and over again it overwrites as a example new data like this and after re-run it vanishes and being preplaces by new one:</p>
  <pre><code>2021-05-02 11:04:15,384, log level: INFO, log content: File was moved to/home/adminas/Documents
  </code></pre>