L
L
LakeForest2021-12-23 11:57:53
Python
LakeForest, 2021-12-23 11:57:53

Error when logging to the console after redefining the log. How to fix?

It logs twice, and before everything it displays an error:
61c438ceae560660174478.png
Crashes to `port=os.getenv("ACCESS_POINT_PORT_IN"))`, but I use my logger in the `controllers.routers_api` module

import os
import uvicorn
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from controllers.routers_api import router

if __name__ == "__main__":
    uvicorn.run("main:app",
                host="0.0.0.0",
                port=os.getenv("ACCESS_POINT_PORT_IN"))


controllers.routers_api
from log import get_logger

logger = get_logger(__name__)
@router.get("/")
async def check():
    logger.info("Клиент подключился к серверу")
    return "200"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2021-12-23
@LakeForest

Well, something that logs twice - maybe because you did not disable the default logger for unicorn.
Reconfigure logging so that the logger's name is shown in the text, it will be clearer who writes what.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question