.claude/skills/railway-logs/SKILL.md
Railway log access and analysis for debugging and monitoring. Covers build logs, deploy logs, runtime logs, HTTP logs, filtering, search, and external export. Use when viewing logs, debugging Railway deployments, investigating errors, analyzing HTTP requests, filtering log output, or exporting logs to external systems.
npx skillsauth add adaptationio/skrillz railway-logsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Access and analyze Railway logs for debugging and monitoring applications.
Railway provides comprehensive logging across the deployment lifecycle:
All logs support filtering, search, and can be exported to external systems for long-term retention.
Keywords: Railway logs, build logs, deploy logs, runtime logs, HTTP logs, log filtering, log search, debugging, monitoring, observability
Important: CLI logs require a linked project with Account Token:
# 1. Set Account Token (NOT project token)
export RAILWAY_API_TOKEN=<your-account-token>
# 2. Link project/environment/service
railway link -p <PROJECT_ID> -e <ENVIRONMENT_ID> -s <SERVICE_ID>
# Example:
railway link -p f8fff4f1-1541-4a47-b509-0c30b9459275 \
-e 3aa108f4-781d-433c-9eee-875c3dbe903d \
-s 4b879f5f-5e42-4804-a67c-2a1ff2475cb3
# 3. Verify link
railway status
See cli-commands.md for complete reference.
Access build process logs to debug compilation and dependency issues.
CLI Commands:
# Stream build logs (live)
railway logs --build
# Last 100 lines of build logs
railway logs --build --lines 100
# Build logs for specific deployment
railway logs --build <DEPLOYMENT_ID>
# Export build logs to file
railway logs --build --lines 500 > build-logs.txt
Dashboard Access:
What to Look For:
Common Issues: | Issue | Solution | |-------|----------| | Dependencies not installing | Check package.json/requirements.txt | | Build timeout | Optimize build process or increase timeout | | Missing build command | Set in Railway dashboard or railway.json | | Cache issues | Force rebuild without cache |
See Also: railway-troubleshooting for cache busting
Monitor deployment lifecycle and health check status.
CLI Commands:
# Stream deployment logs (live)
railway logs --deployment
# Last N lines of deploy logs
railway logs --deployment --lines 200
# Specific deployment by ID
railway logs --deployment <DEPLOYMENT_ID>
# Export deploy logs
railway logs --deployment --lines 500 > deploy-logs.txt
Dashboard Access:
Deployment Phases:
Health Check Debugging:
# View health check failures
railway logs --deployment | grep "health check"
# Common health check issues:
# - Port not exposed correctly
# - Application not binding to 0.0.0.0
# - Health endpoint not responding
# - Application crashing during startup
Troubleshooting:
PORT environment variableAccess application stdout/stderr for debugging runtime behavior.
CLI Commands:
# Stream runtime logs (live, Ctrl+C to stop)
railway logs
# Last N lines (stops streaming)
railway logs --lines 500
# Stream different service/environment
railway logs --service backend --environment production
# Filter with Railway syntax
railway logs --filter "@level:error"
railway logs --lines 100 --filter "timeout"
# Pipe to grep for local filtering
railway logs | grep ERROR
# JSON output for parsing
railway logs --json | jq 'select(.level == "error")'
Dashboard Access:
Structured Logging Best Practices:
Railway supports structured JSON logging. Output JSON on a single line:
// Node.js Example
console.log(JSON.stringify({
level: 'error',
message: 'Database connection failed',
error: err.message,
timestamp: new Date().toISOString(),
userId: req.user?.id
}));
# Python Example
import json
import logging
logging.basicConfig(format='%(message)s')
logger = logging.getLogger()
logger.error(json.dumps({
'level': 'error',
'message': 'Database connection failed',
'error': str(e),
'timestamp': datetime.utcnow().isoformat(),
'user_id': user_id
}))
Supported Log Levels:
debug - Detailed diagnostic informationinfo - General informational messageswarn - Warning messages (potential issues)error - Error messages (failures)Benefits:
Analyze HTTP request patterns and debug API issues.
Dashboard Access:
Available Metadata:
Filtering HTTP Logs:
# Filter by status code
@httpStatus:500
# Filter by path
@path:"/api/users"
# Combine filters
@httpStatus:500 AND @path:"/api"
Use Cases:
Performance Analysis:
# Find slow requests (>1000ms)
# Filter in dashboard: responseTime > 1000
# Find all 5xx errors
# Filter: @httpStatus:5xx
# Analyze specific endpoint
# Filter: @path:"/api/checkout"
Use Railway's powerful filtering syntax for targeted log analysis.
Filter Syntax:
| Filter | Example | Description |
|--------|---------|-------------|
| Substring | "error" | Search for text |
| HTTP Status | @httpStatus:500 | Filter by status code |
| Service ID | @service:<id> | Filter by service |
| Log Level | @level:error | Filter by severity |
| Custom Field | @userId:123 | Filter by JSON field |
Boolean Operators:
# AND - Both conditions must match
@httpStatus:500 AND @path:"/api"
# OR - Either condition matches
@level:error OR @level:warn
# NOT - Exclude matches
NOT @path:"/health"
# Grouping
(@level:error OR @level:warn) AND @service:api
Common Filter Patterns:
# All errors from last hour
@level:error
# Slow HTTP requests (>1000ms)
@httpStatus:200 AND responseTime > 1000
# Failed API calls
@path:"/api" AND @httpStatus:5xx
# Exclude health checks
NOT @path:"/health" NOT @path:"/metrics"
# Specific user errors
@level:error AND @userId:12345
# Database connection issues
"connection refused" OR "timeout"
Dashboard Filtering:
CLI Filtering:
# Use grep for basic filtering (streaming is default)
railway logs | grep ERROR
# Use jq for JSON logs
railway logs --json | jq 'select(.level == "error")'
# Complex filtering with awk
railway logs | awk '/ERROR/ || /WARN/'
Export logs to external systems for long-term retention and analysis.
Why Export?
External Export Options:
Deploy a sidecar container to forward logs via webhooks.
Repository: https://github.com/railwayapp/locomotive
Setup:
# Add locomotive service to Railway project
railway service create locomotive
# Configure environment variables
WEBHOOK_URL=https://your-log-endpoint.com/ingest
WEBHOOK_METHOD=POST
WEBHOOK_HEADERS='{"Authorization": "Bearer xxx"}'
# Deploy locomotive
railway up
Supported Destinations:
Send logs using OTEL protocol.
Environment Variables:
# Add to your service
OTEL_EXPORTER_OTLP_ENDPOINT=https://otel-collector.example.com:4318
OTEL_EXPORTER_OTLP_HEADERS=x-api-key=xxx
OTEL_SERVICE_NAME=my-railway-service
Supported OTEL Collectors:
See Also: observability-stack-setup for LGTM stack
Use the provided script to stream logs to external systems.
Usage:
# Stream to file
.claude/skills/railway-logs/scripts/stream-logs.sh --output file --path logs/
# Stream to webhook
.claude/skills/railway-logs/scripts/stream-logs.sh --output webhook \
--url https://logs.example.com/ingest \
--token YOUR_API_KEY
# Stream to S3
.claude/skills/railway-logs/scripts/stream-logs.sh --output s3 \
--bucket my-logs-bucket \
--prefix railway/
Features:
Export logs for ad-hoc analysis.
# Export last 1000 lines
railway logs --lines 1000 > logs-$(date +%Y%m%d-%H%M%S).txt
# Export recent logs (specify number of lines)
railway logs --lines 1000 > logs-recent.txt
# Export and compress
railway logs --lines 5000 | gzip > logs.txt.gz
Scheduled Export (cron):
# Add to crontab (every 6 hours)
0 */6 * * * railway logs --lines 10000 > /backup/railway-logs-$(date +\%Y\%m\%d-\%H\%M).txt
# Install Datadog agent in Railway
# Add environment variables:
DD_API_KEY=xxx
DD_SITE=datadoghq.com
DD_LOGS_ENABLED=true
DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true
# Use locomotive sidecar
WEBHOOK_URL=https://api.axiom.co/v1/datasets/<dataset>/ingest
WEBHOOK_HEADERS='{"Authorization": "Bearer <token>"}'
# Add to your application
LOGTAIL_SOURCE_TOKEN=xxx
# Use Logtail SDK
npm install @logtail/node
# Deploy Grafana Agent/Alloy
# Configure to scrape Railway logs
# See observability-stack-setup skill
DO:
console.log(JSON.stringify({ level: 'info', message: 'User login', userId: 123 }));
DON'T:
console.log(`User ${userId} logged in`); // Hard to search/filter
Use appropriate severity:
debug - Development/troubleshooting onlyinfo - Normal operationswarn - Potential issues (high memory, slow queries)error - Failures requiring attentionNEVER log:
Redact sensitive data:
console.log(JSON.stringify({
level: 'info',
message: 'User login',
email: 'u***@example.com', // Redacted
ip: req.ip
}));
Avoid excessive logging:
// BAD - Logs every request
app.use((req, res, next) => {
console.log(`Request: ${req.method} ${req.path}`);
next();
});
// GOOD - Log only errors or important events
app.use((req, res, next) => {
if (res.statusCode >= 400) {
console.log(JSON.stringify({ level: 'error', method: req.method, path: req.path, status: res.statusCode }));
}
next();
});
For production:
| Issue | Solution | |-------|----------| | Logs not appearing | Check application is writing to stdout/stderr | | JSON logs not parsing | Ensure JSON is on single line (no newlines) | | Logs truncated | Railway may truncate very long log lines (>10KB) | | Missing logs | Check log retention period for your plan | | Can't filter by custom field | Verify field is in structured JSON log | | High log volume | Reduce logging verbosity, sample logs |
| Task | Command |
|------|---------|
| Stream runtime logs | railway logs |
| Last N lines | railway logs --lines 100 |
| Build logs | railway logs --build |
| Deploy logs | railway logs --deployment |
| Export to file | railway logs --lines 500 > output.txt |
| Filter errors | railway logs \| grep ERROR |
| JSON filtering | railway logs --json \| jq 'select(.level == "error")' |
Use CLI for logs, not API. The Railway GraphQL API log queries (deploymentLogs, buildLogs) often return "Problem processing request". The CLI provides reliable log access:
railway logs # Runtime logs
railway logs --deployment # Build/deploy logs
railway logs --lines 100 # Historical logs
See railway-api/references/api-limitations.md for details.
See the references/ directory for detailed guides:
See the scripts/ directory for automation tools:
Last Updated: 2025-11-26
development
Setup secure web-based terminal access to WSL2 from mobile/tablet via ttyd + ngrok/Cloudflare/Tailscale. One-command install, start, stop, status. Use when you need remote terminal access, web terminal, browser-based shell, or mobile access to WSL2 environment.
development
Complete development workflows where Claude writes the code while Gemini and Codex provide research, planning, reviews, and different perspectives. Claude remains the main developer. Use for complex projects requiring expert planning and multi-perspective reviews.
development
Systematic progress tracking for skill development. Manages task states (pending/in_progress/completed), updates in real-time, reports progress, identifies blockers, and maintains momentum. Use when tracking skill development, coordinating work, or reporting progress.
testing
Comprehensive testing workflow orchestrating functional testing, example validation, integration testing, and usability assessment. Sequential workflow for complete skill testing from examples through scenarios to integration validation. Use when conducting thorough testing, pre-deployment validation, ensuring skill functionality, or comprehensive quality checks.