import logging
from logging.handlers import TimedRotatingFileHandler
logger = logging.getLogger('Mainer')
logger.setLevel(logging.INFO)
format = "%(asctime)s - %(levelname)s - %(message)s"
filename = "Reckon_APP.log"
handle = TimedRotatingFileHandler(filename, when="midnight",
interval=5)
handler.setLevel(logging.WARN)
formatter = logging.Formatter(format)
handler.setFormatter(formatter)
handler.suffix = "%Y-%m-%d-%H-%M-%S"
logger.addHandler(handler)
I got to know logfile will not create directly when the app is running in docker. So I used docker volumes to create it. I run the following command. Given local path to desktop(in which path, the file should be created and absolute path is the log file name that I given in the app.
docker run -v /C/Users/DELL/Desktop:/Reckon_APP -p 80:80 --name my_APP My-Own-app
And the app is running with out errors, Still the file is not creating in my local.
CodePudding user response:
I'm not set up to run this in docker, but at a guess, it looks like you are missing the directory in this line:
logname = "Reckon_APP.log"
Instead:
logname = "/Reckon_APP/log.log"