简体   繁体   中英

where the logs are stored if logger = logging.getLogger(__name__)

I have set logger = logging.getLogger(__name__)

and using it like below:

def get_token(self, username, password):
        auth = HTTPBasicAuth(username, password)
        logging.info("%s" % self.base_url)
        try:
            response = requests.post(self.base_url, auth=auth, verify=False)
        except Exception as e:
            logging.error("%s" % str(e))

in which directory should i see the logs?

you can specify two outputs: console (stream) and file output:

settings_folder = os.path.join(os.environ["APPDATA"], "my_app")
logging_file = os.path.join(settings_folder, "app.log")

if not os.path.isdir(settings_folder):
    os.mkdir(settings_folder)

# add logging to console and log file
logging.basicConfig(filename=logging_file, format='%(asctime)s (%(levelname)s) %(message)s', level=logging.DEBUG,
                    datefmt='%d.%m.%Y %H:%M:%S')
logging.getLogger().addHandler(logging.StreamHandler())

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM