Logs being flagged as Errors
Hi, I'm using the Python module (https://docs.python.org/3/library/logging.html) to differentiate logs however on the Railway logs it doesn't seem to differentiate between Warnings and Errors and just labels everything with an Error level. It could be something with my configuration but curious if anyone else has encountered this or have a logging configuration that works for them?
Python documentation
logging — Logging facility for Python
Source code: Lib/logging/init.py Important: This page contains the API reference information. For tutorial information and discussion of more advanced topics, see Basic Tutorial, Advanced Tutor...
Solution:Jump to solution
They are counted as errors because they are printed to stderr, if you want colored logs for info, error, warn, debug -- you will need to use JSON logging
7 Replies
Project ID:
c61c1785-a8d8-43d0-9d8b-6bd1f69aa3bf
c61c1785-a8d8-43d0-9d8b-6bd1f69aa3bf
Solution
They are counted as errors because they are printed to stderr, if you want colored logs for info, error, warn, debug -- you will need to use JSON logging
Ah, assuming something like: https://github.com/madzak/python-json-logger
GitHub
GitHub - madzak/python-json-logger: Json Formatter for the standard...
Json Formatter for the standard python logger. Contribute to madzak/python-json-logger development by creating an account on GitHub.
I'm not a python guy, but I assume so too
no need for a library, just send the correct log level to the correct output
any logs greater than warning will go to stderr
more people need to use JSON logging