Info logs are being treated as error logs in python
connorshinn
HOBBYOP

2 years ago

I have deployed an appllication in railway.app which runs every 15 minutes.
When I open observability tab, I see errors every 15 minute interval (ie every time my app ran). But when I check the logs, all are info logs.

My info logs are being treated as error logs in the observablity section.

Any way to see them separately, other wise its becoming very hard to find instances when things actually went wrong

Thanks

9 Replies

2 years ago

Your logs are red because you are logging to stderr, instead, I can not recommend structured JSON logging enough, Railway has amazing support for it and will color all your logs to the correct level, instead of just red for stderr and no color for stdout.


connorshinn
HOBBYOP

2 years ago

Sry, this is the first time I am hearing about JSON logging, can you help me understand how I can incorporate it in my python app?


2 years ago

Yep as mentioned before your logs are red because you are logging to stderr, now would be a great time to switch over to structured JSON logging.


2 years ago

Well, you edited your message so now I look like I'm talking to myself.

There are many great resources on structured JSON logging for Python out there, just look!


connorshinn
HOBBYOP

2 years ago

Sry for editing my first comment, I hadn't refreshed my page in a while and had started editing before i saw your comment.

Ok, found something online will check it out. Thanks


2 years ago

Real-time forum comments coming soon!

Edit, the forum comments now update in real-time!!


trentprynn
HOBBY

2 years ago

Agreed on the use of structured logging being a good idea but it's strange to me that standard python logs to stdinfo like logging.info('hello world') show up on stderror in railway -- this doesn't make a ton of sense to me


2 years ago

stdinfo is not a thing on any OS.

'logging.info()' by default sends the logs to stderr, thus get coloured red.


2 years ago

You should be able to configure a StreamHandler [0] to make it log to sys.stdout instead of sys.stderr.

[0] https://docs.python.org/3/library/logging.handlers.html#streamhandler


Loading...