From: https://gitlab.com/euri10/euri10_fastapi_base
euri10 @euri10 Jun 27 09:31 well I just did it, quite simple in fact L) will add it to my logging facility you can see it here : euri10/euri10_fastapi_base@814404f in summary I added this to my docker-compose
healthcheck:
test: ["CMD", "wget", "http://localhost:8000/healthcheck"]
interval: 1s
which effectively spams the logger every second
@app.get("/healthcheck")
async def healthcheck():
return {"status": "alive"}
now it depends how logging is performed on your app in my case everything is configured through a logging.yaml that is read at app initialization and then setup with
logging.config.dictConfig(logging_config)
euri10 @euri10 Jun 27 09:38 so depending on how you configuire it, the only thing to know is you add a filter to the handler that spits the log you want to avoid,
then you declare a custom filter , it's here : https://gitlab.com/euri10/euri10_fastapi_base/blob/814404fc44636c8ebd04af91e33cb325f72db294/python3.7-alpine3.8/app/applog/logging.yml#L41
then you write that custom filter class subclassing logging.Filter, its here https://gitlab.com/euri10/euri10_fastapi_base/blob/814404fc44636c8ebd04af91e33cb325f72db294/python3.7-alpine3.8/app/applog/utils.py#L32 pretty simple in fact