8 months ago
We'll no longer be using nginx when if we move to Railway. However our tech SEO team needs HTTP logs with nginx-level detail (e.g. http_user_agent, http_x_forwarded_for, sent_http_location, etc.). How can we export this level of detail from railway?
Currently you don't seem to be able to download 'HTTP logs' from Railway at all (only deployment-specific deploy/build logs are possible to download). And only 5000 lines at a time (our team requires logs for a whole day).
The Railway docs appears to show a screenshot of this kind of nginx-style logs (see just below 'Command Line' here), but I can't seem to get the Railway CLI to output this (not given an option for 'HTTP Logs').
5 Replies
8 months ago
Hi there
AFAIK railway logs returns the application logs at least for rails apps it will output the contents of /log/production.log
that means you can log any additional info you need
if you could let me know what is your tech stack, i.e. language / framework along with the values you want to capture, i could propose a way to surface the info you need
thanks
alex
8 months ago
Thanks for getting back Alex.
We have a nodejs express app. We can modify our express middleware logger to log the fields we need (such as http_user_agent, http_x_forwarded_for, sent_http_location,), but these will then appear mixed up with all the rest of our web server logs inside Railway's "Deploy logs".
What we want is to have Railway's "HTTP Logs" output more fields as is possible with nginx (currently Railway's "HTTP Logs" only outputs Timestamp, Method, Path, Status, Response Time).
8 months ago
We don't support a way for the user to add more fields to our HTTP Logs.
Like alex suggested, you would want to log this information yourself, but you would want to log it as JSON so that you can easily apply a filter to show only HTTP Logs that your application printed.
https://docs.railway.com/guides/logs#filtering-logs
8 months ago
Thanks for the help guys
I've got a solution working now using Railway's Locomotive template which pipes to Grafana Cloud using Loki. Have added the extra fields I needed to our Morgan http logger, and then added a custom attribute for filtering out only the http logs.
8 months ago
Awesome!
But I also need to mention that's not our template, that is a community member's template, though we do endorse it heavily so I'm glad it's working for you!
Status changed to Awaiting User Response Railway • 8 months ago
6 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 • 6 months ago