Log timestamp from application
davidvandewalle
PROOP

2 years ago

I have read the Railway log guide and wanted to know if the Railway logs can take the timestamp from our structured logs instead of adding a timestamp by Railway.

for example structured log entry

{"tst": "2024-05-03T12:48:10.497Z", "level":"error", "msg":"Something bad happened"}

instead of

{"level":"error", "msg":"Something bad happened"}

The advantage is more precise logfiles with the exact timing of the event and not of the stderr.

Is there a specific keyword we need to use to add the timestamp, or is this functionality not available?

Solved

3 Replies

2 years ago

You can definitely add your own timestamp attribute and filter by that in the search, but Railway would not use the timestamp attribute from your logs in place of the timestamp they add on.

I'm curious what your usecase for this would be? are you noticing that the timestamp added by Railway is significantly off from the timestamp your app prints?


davidvandewalle
PROOP

2 years ago

In some cases, I run async batch tasks and receive the results when the batch is done.

I can only write the log when I process the results after the task is completed, so I print the messages to stdout or stderr with a delay.

In such a case, it would be great to add the timestamp to the main timestamp field of the log. Otherwise, the timestamp in the log is not correct.


2 years ago

What about printing a log when the task starts with the task id and then print the log when it completes with the same task id so that you can filter by the id?


Status changed to Awaiting User Response christian over 1 year ago


Railway
BOT

7 months ago

This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!

Status changed to Solved Railway 7 months ago


Loading...