How to log to disk daily?
jymchng opened this issue · comments
Jim Chng commented
Hi @jonra1993,
I am using logger = logging.getLogger(__name__)
to do my logging at DEBUG
level.
How do I dump these logs daily to disk? Thank you.
Jonathan Vargas commented
@jymchng I think you should do something like this
import logging
from fastapi import FastAPI
app = FastAPI()
logger = logging.getLogger(__name__)
log_handler = logging.FileHandler(filename="app.log")
logger.addHandler(log_handler)
@app.get("/")
async def root():
logger.info("Received request at root endpoint")
return {"message": "Hello World"}
Jim Chng commented
How about storing the logs in minio?
Jim Chng commented
How about storing the logs in minio?
@jonra1993 Sir, what do you think of this?
Jonathan Vargas commented
Hello @jymchng I do not think any reason why it should not work I I am going to add it to todo list.