Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to log to disk daily? #64

Open
jymchng opened this issue Apr 20, 2023 · 4 comments
Open

How to log to disk daily? #64

jymchng opened this issue Apr 20, 2023 · 4 comments

Comments

@jymchng
Copy link
Contributor

jymchng commented Apr 20, 2023

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.

@jonra1993
Copy link
Owner

jonra1993 commented Apr 20, 2023

@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"}

@jymchng
Copy link
Contributor Author

jymchng commented Apr 23, 2023

How about storing the logs in minio?

@jymchng
Copy link
Contributor Author

jymchng commented May 4, 2023

How about storing the logs in minio?

@jonra1993 Sir, what do you think of this?

@jonra1993
Copy link
Owner

Hello @jymchng I do not think any reason why it should not work I I am going to add it to todo list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants