我正在尝试在路径中写入日志,但是日志并未以长期尝试的不同方式在路径中写入日志。
帮我在路径中写日志
from flask import Flask
from apscheduler.scheduler import Scheduler
import atexit
import threading
import time
import logging
app = Flask(__name__) #flask app
base_dir_app_log="/Users/test/Downloads/logs/"
@app.route("/", methods=['GET'])
def hello():
return "Hello World!"
if __name__ == '__main__':
log_dir = os.path.join(base_dir_app_log,"logs/webmonitoring")
logfile = os.path.join(log_dir, "Webmonitoring_flask" + datetime.now().strftime('_monitoring_log_%Y_%m_%d_%I_%M_%S.log'))
logging.basicConfig(format='%(asctime)s:%(levelname)s:%(message)s', datefmt='%m/%d/%Y %I:%M:%S %p', filename=logfile, level=logging.INFO)
print ('-------------------------------- START ---------------------------------')
logging.info ('< --------- START ---------------------- >')
app.run()