Uvicorn is stopping logging to file #2838
Unanswered
stuartofmt
asked this question in
Q&A
Replies: 1 comment
-
|
This is expected behavior. When Uvicorn starts, it applies its own logging configuration, which can end up overriding any custom handlers you defined earlier. A way to avoid this is to pass import uvicorn
uvicorn.run(app, host=UI.HOST, port=UI.PORT, log_config=None)If you'd still like to use Uvicorn's default logging while adding your own (for example, a file handler), you can customize the Also, just as a heads-up, the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using uvicorn as part of a wider python application.
In my application, I configure a logger using logging that has both a streamhandler (c_handler = logging.StreamHandler(sys.stdout)) and a filehandler (f_handler = logging.FileHandler(logfile, mode='w', encoding='utf-8'))
This all works fine until uvicorn starts, at which point the filehandler stops logging to the file - although the output to the console still works.
How to prevent uvicorn from "killing" the filehandler? I.e. My 'perfect' outcome is that uvicorn continues to use the same handlers as I defined in the main code.
I start uvicorn thus:
uvicorn.run(app,
host=UI.HOST,
port=UI.PORT
)
Would 'no-access-log' work? If so - what is the appropriate keyword (the documentation seems silent on this :-(
Thanks in advance
Beta Was this translation helpful? Give feedback.
All reactions