Answer the question
In order to leave comments, you need to log in
How to organize logging in a python application?
Good afternoon! I look forward to hearing from more experienced colleagues.
What is the best way to organize logging in a python application that is launched via systemd or in docker, is it possible in this case to send everything to stdout, stderr, and write to files on the shoulders of systemd, docker?
For logging at the application level, I see the advantages in the fact that we can more flexibly with different filters, handlers lay out everything in files with rotation.
For higher level logging, ease of setup and less logging-related code will be an advantage.
This is especially about blocking handlers, smtp, file, or a custom TelegrammHandler in asynchronous or Web applications. In the logging library recipes, in this case it is proposed to use QueueListner, QueueHandler, but this is again a complication at the application level.
Or does it all depend on the situation? Then in what case to apply that and other approach?
Answer the question
In order to leave comments, you need to log in
Throw errors in sentry, the rest depends purely on your desire and convenience. I never really bothered with logs, for some services it was necessary to write the progress, I used boxed logging or loguru, writing to a file, in the case of docker, you can mount it in a separate directory.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question