Go Slog JSON Handler

2 years ago

I am in the process of migrating from Logrus to Slog in my go application. I am using the NewJSONHandler method to initialise the logger and I set the logger as the default in init()

When I immediately log (using slog.Info) after initialising the new default, I only receive the message.

Why I'm wondering if this is a Railway issue is:

a) Even the default logger prepends "INFO" to the message

b) Using this approach in the rest of my infrastructure (not running on Railway) works correctly

If this doesn't sound like an issue with your logs I'm happy to continue debugging, but I just wanted to rule it out 🙂

Thanks!

Solved

12 Replies

2 years ago

b7ffa58d-4fc3-417f-8ad8-ffc29078d847


2 years ago

Also while I'm here, I don't have pro plan. I briefly upgraded but my role on discord has never been removed


2 years ago

can you show me a screenshot of what your log looks like expanded?


2 years ago

Sigh... I didn't realise you could expand the logs 😅

Thanks for the help again Brody 🙏


2 years ago

how could we have made that more visually obvious?


2 years ago

I think part of why I didn't end up expanding the log is that previously with logrus I wasn't using JSON logging so when I did expand the logs in the past I would just see:

deployment: 31325692-cfbf-4a1d-af09-dbb1c6e0a28a
replica: 0195d686-91f3-46a2-a6c8-437c84f7201b
service: 5d663c81-9cc5-4209-87f6-d81b06b48e83

I assumed expanding the log just showed Railway metadata.

Maybe it's the FE experience in me but, in front of the log message adding a {...} or similar? Also allowing click on the whole log instead of just the little "+" would be great! 🙂

1328236016275816530


2 years ago

what if we showed that plus icon on logs that have extra JSON attributes, instead of only showing on hover


2 years ago

I think that would also definitely help


2 years ago

Thanks Brody! Appreciate the help 🙂


2 years ago

no problem, I'll bring that UI change up to our product team to see if they like the idea too


2 years ago

but for now, I'll mark this as solved, feel free to open a new thread if you have anymore questions


2 years ago

!s


Status changed to Solved brody over 1 year ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...