Created
          January 16, 2021 19:56 
        
      - 
      
- 
        Save Liad-n/8116714af87193e2a4159a1537c1c28c to your computer and use it in GitHub Desktop. 
    basic_logging
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | log_file_path = r'log.log' | |
| logger = logging.getLogger() | |
| logger.setLevel(logging.DEBUG) | |
| LOG_FORMAT = "%(levelname)s %(asctime)s - %(message)s" | |
| formatter = logging.Formatter(LOG_FORMAT, datefmt="%Y-%m-%d %H:%M:%S") | |
| file_handler = logging.FileHandler(log_file_path) | |
| file_handler.setLevel(logging.DEBUG) | |
| file_handler.setFormatter(formatter) | |
| stream_handler = logging.StreamHandler(sys.stdout) | |
| stream_handler.setLevel(logging.INFO) | |
| logger.addHandler(file_handler) | |
| logger.addHandler(stream_handler) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment