i have a logger in a webapp, I initialize the logger from config.ini, and feed the config.ini to the app on server start. runApp.bat
uvicorn api.main:app --host 127.0.0.1 --port 8000 --log-config \path\logconfig.ini
the app is a fastAPI project.
config.ini
[loggers]
keys=root
[handlers]
keys=logfile
[formatters]
keys=logfileformatter
[logger_root]
level=INFO
handlers=logfile
[formatter_logfileformatter]
format=[%(asctime)s.%(msecs)03d] %(levelname)s [%(thread)d] - %(message)s
[handler_logfile]
class=handlers.RotatingFileHandler
args=('C:\\path\\api.log', 'a', 1024, 1000)
right now the logs are rotated based on size, once it reaches 1024bytes it creates a new one what i want is to also rotate based on time so if the file has 500 bytes but for example 10 seconds pass by i want to create a new file either way
[handler_logfile]
class=handlers.TimedRotatingFileHandler
level=INFO
args=('C:\\path\\api.log', 's', 10, 0)
this is how i call the logger in main.py
logging.basicConfig(
level=logging.INFO,
)
@app.get("/", include_in_schema=False)
.
.
.
adding one rotator works but i dont know how to add both?