6 months ago
Description
I'm experiencing an issue where railway logs command only retrieves up to 500 lines when outputting to a file, regardless of the actual log size.
Issue
When I execute
bashrailway logs > logs.txt
# or
railway logs --json > logs.jsonThe output file only contains the most recent 500 lines of logs.
However, I need to retrieve logs from the past 3 days (August 14-16), but older logs beyond 500 lines are not included.
Expected behavior
Should be able to retrieve all logs within the retention period (30 days for Pro plan).
Actual behavior
Only the latest 500 lines are saved to the file.
Has anyone encountered this issue? Is there a line limit for the railway logs command?
9 Replies
6 months ago
I believe if you download the logs from the UI then it'll download the last 1000 log lines
If that's not enough then there's two other options I can recommend:
downloads the last 5000 log lines for a deployment. It's quick and easy to use since its just a bookmarklet (or you can just copy paste the code in the inspect element console)
downloads 100% of the available logs for a service or deployment (even if that exceeds 5000 log lines). Bit more of a setup since you need go and then need to configure your account token
-# Both of these tools were made by Brody, a Railway employee
6 months ago
Alternatively, you can use a GraphQL query yourself to fetch the logs:
query GetEnvironmentLogs(
$environmentId: String!,
$filter: String,
$anchorDate: String,
$afterDate: String,
$afterLimit: Int,
$beforeDate: String,
$beforeLimit: Int
) {
environmentLogs(
environmentId: $environmentId,
filter: $filter,
anchorDate: $anchorDate,
afterDate: $afterDate,
afterLimit: $afterLimit,
beforeDate: $beforeDate,
beforeLimit: $beforeLimit
) {
attributes {
key
value
}
message
severity
tags {
deploymentId
deploymentInstanceId
environmentId
pluginId
projectId
serviceId
snapshotId
}
timestamp
}
}you can set the filter to target your specific deployment or filter or anything else and set the before and after dates and limits as needed to fetch what you need
6 months ago
-# ^ this is limited to 5000 log lines max so if you need more than that then you may need to call this multiple times
6 months ago
Alternatively, you can use this tool I wrote to fetch logs without line amount limitations -
@Fragly @Brody
Thank you very much!
Thanks to this tool, I was able to resolve the issue.
I was able to download all logs for each deployment as well as logs across deployments. Thank you very much for providing such a wonderful service.
https://github.com/brody192/railway-log-downloader
6 months ago
Happy to help!
6 months ago
!s
Status changed to Solved brody • 6 months ago