8 months ago
We use pino to structure our logs. Pino includes a level
property with values between 10 and 60 in all logs. Railway overrides this value with either "info"
or "error"
. We need to access pino's level to better filter our logs.
Is there a way to disable overriding properties in the structured log? Ideally you would move railway's level
out of the log line and into the same group as the deployment
, replica
, and service
ids.
5 Replies
8 months ago
Unfortunately we can't do this without breaking a ton of other stuff that depends on it
Can Pino be configured to move that property to a different key?
Status changed to Awaiting User Response railway[bot] • 8 months ago
8 months ago
Unfortunately, pino does not allow this. On a related note it seems railway is swallowing the severity
key.
Status changed to Awaiting Railway Response railway[bot] • 8 months ago
8 months ago
I'm afraid there's nothing we can do about this at the moment, sorry. Tweaking the way we present log level may introduce breaking changes and we're unable to prioritize such a change at this time.
We convert severity
into the log level internally so they're treated as level
.
Would you be able to transform the numerical values into their corresponding labels (10=DEBUG, 20=INFO, ...)? I'm not familiar with Pino in particular, but loggers generally allow you to transform their output via a formatter or a similar primitive.
Status changed to Awaiting User Response railway[bot] • 8 months ago
8 months ago
Made the change and railway now shows the proper log level. Ideally it would simply infer the level and not override it, but this works too. All I did was add this to the pino config:
const logger = pino({
formatters: {
level(label) {
return { level: label };
},
},
});
Status changed to Awaiting Railway Response railway[bot] • 8 months ago
8 months ago
Nice!
Yep we'll look into why numerical values don't translate into their appropriate labels. Thanks
Status changed to Awaiting User Response railway[bot] • 8 months ago
Status changed to Solved ray-chen • 8 months ago