# How to view real-time logs in Replit

- Tool: Replit
- Difficulty: Beginner
- Time required: 10-15 minutes
- Compatibility: All Replit plans (Starter, Core, Pro). Core or Pro required for deployments. Works with any language.
- Last updated: March 2026

## TL;DR

Replit provides three places to view logs: the Console tab for development output, the Shell tab for interactive commands, and the deployment Logs tab for production. The Console shows structured output from the Run button including stdout, stderr, and duration. Deployed apps stream logs to the Logs tab in the Deployments pane. Add structured logging with timestamps using Python's logging module or a Node.js logger like winston for production-grade log management.

## View and Stream Real-Time Logs for Your Replit Application

This tutorial explains where logs appear in Replit during development and production, how to add structured logging to your application, and how to use logs to diagnose issues. You will learn the difference between Console and Shell output, how to read deployment logs, and how to set up structured logging with timestamps and severity levels that make debugging production issues much faster.

## Before you start

- A Replit account (free Starter plan works for development logging)
- A Replit App with a running web application
- Basic familiarity with the Replit workspace (Console, Shell, Preview pane)
- Core or Pro plan required for deployment log viewing

## Step-by-step guide

### 1. Understand Console vs Shell vs deployment Logs

Replit has three distinct places where output appears, and each shows different information. The Console tab shows output from the Run button — it displays structured entries with stdout, stderr, execution duration, and status metadata. The Shell tab is an interactive terminal for running commands manually — its output is separate from the Console. The deployment Logs tab (in the Deployments pane) shows output from your production application. Client-side JavaScript logs (from console.log in browser code) do NOT appear in any of these — they only show in the Preview pane's browser DevTools (right-click Preview, Inspect, Console tab).

**Expected result:** You understand that Console = Run button output, Shell = manual commands, Logs tab = deployed app output, and browser DevTools = client-side JavaScript.

### 2. View development logs in the Console

Press the Run button to start your application. All server-side output — print() in Python, console.log() in Node.js — appears in the Console tab. The Console shows each entry with the command that was run, the output text, and whether it went to stdout or stderr. If your app crashes, the error traceback or stack trace appears here. You can scroll through the Console to see historical output from the current session. Output clears when you stop and restart the app.

```
# Python — server-side logging visible in Console:
print("Server started on port 3000")
print(f"Received request: {request.path}")

# Node.js — server-side logging visible in Console:
console.log('Server started on port 3000');
console.log(`Received request: ${req.path}`);
console.error('Database connection failed');  // Shows as stderr
```

**Expected result:** Pressing Run shows your application's output in the Console tab with clear separation between stdout and stderr entries.

### 3. Add structured logging with timestamps

Plain print() and console.log() work for quick debugging but become hard to read in production. Add structured logging with timestamps, severity levels, and context information. For Python, use the built-in logging module. For Node.js, use winston or pino. Structured logs make it much easier to filter for errors, trace request flows, and diagnose timing issues in the deployment Logs tab.

```
# Python — structured logging:
import logging

logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s [%(levelname)s] %(name)s: %(message)s',
    datefmt='%Y-%m-%d %H:%M:%S'
)
logger = logging.getLogger('myapp')

logger.info('Server started on port 3000')
logger.warning('Slow response: 2.5 seconds')
logger.error('Database query failed: connection timeout')

# Output:
# 2026-03-27 10:30:00 [INFO] myapp: Server started on port 3000
# 2026-03-27 10:30:05 [WARNING] myapp: Slow response: 2.5 seconds
# 2026-03-27 10:31:00 [ERROR] myapp: Database query failed: connection timeout
```

**Expected result:** Your application output includes timestamps and severity levels, making it easy to filter for errors and trace timing issues.

### 4. Add request logging for web applications

For web applications, log every incoming request with the method, path, status code, and response time. This creates an audit trail that helps you understand traffic patterns and identify slow endpoints. For Flask apps, use the after_request decorator. For Express apps, use middleware. These logs appear in both the Console during development and the deployment Logs tab in production.

```
# Python Flask — request logging:
import time
import logging
from flask import Flask, request, g

app = Flask(__name__)
logger = logging.getLogger('myapp')

@app.before_request
def start_timer():
    g.start_time = time.time()

@app.after_request
def log_request(response):
    duration = (time.time() - g.start_time) * 1000
    logger.info(
        f"{request.method} {request.path} → {response.status_code} "
        f"({duration:.0f}ms)"
    )
    return response

# Output:
# 2026-03-27 10:30:00 [INFO] myapp: GET /api/users → 200 (45ms)
# 2026-03-27 10:30:01 [INFO] myapp: POST /api/login → 401 (120ms)
```

**Expected result:** Every HTTP request to your server produces a structured log entry with method, path, status code, and response duration.

### 5. View production logs in the deployment Logs tab

After deploying your application (Autoscale, Reserved VM, or Scheduled), open the Deployments pane and click the Logs tab. This shows real-time output from your production application including all print(), console.log(), and logging output. Use the Logs tab to verify your app started correctly, monitor for errors, and track request patterns. Logs stream in real time — new entries appear automatically as they are generated. If no logs appear, your app may have crashed during startup; check for missing Secrets or port binding issues.

**Expected result:** The Logs tab in the Deployments pane shows real-time output from your production application, including structured log entries with timestamps.

### 6. Add error alerting to your logs

The deployment Logs tab does not send notifications when errors occur. To get alerted about production issues, add error reporting to your logging setup. The simplest approach is to send a webhook to Slack or Discord when a critical error occurs. Wrap your main request handler in a try/except that catches unhandled exceptions and sends an alert before returning an error response. Store the webhook URL in Tools → Secrets.

```
import os
import json
import logging
import urllib.request

logger = logging.getLogger('myapp')

def send_alert(message):
    """Send error alert to Slack webhook."""
    webhook_url = os.getenv('SLACK_WEBHOOK_URL')
    if not webhook_url:
        return
    try:
        payload = json.dumps({'text': f':rotating_light: {message}'}).encode()
        req = urllib.request.Request(
            webhook_url,
            data=payload,
            headers={'Content-Type': 'application/json'}
        )
        urllib.request.urlopen(req)
    except Exception as e:
        logger.error(f'Failed to send alert: {e}')

# Use in error handling:
try:
    result = process_request(data)
except Exception as e:
    logger.exception('Unhandled error in process_request')
    send_alert(f'Production error: {e}')
    return {'error': 'Internal server error'}, 500
```

**Expected result:** When a critical error occurs in production, an alert is sent to your Slack channel and the error details are logged to the Logs tab.

## Complete code example

File: `main.py`

```python
# main.py — Flask app with comprehensive logging for Replit
import os
import time
import json
import logging
import urllib.request
from flask import Flask, request, g, jsonify

# Configure structured logging
logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s [%(levelname)s] %(name)s: %(message)s',
    datefmt='%Y-%m-%d %H:%M:%S'
)
logger = logging.getLogger('myapp')

app = Flask(__name__)


def send_alert(message):
    """Send error notification to Slack."""
    webhook_url = os.getenv('SLACK_WEBHOOK_URL')
    if not webhook_url:
        return
    try:
        payload = json.dumps({'text': message}).encode()
        req = urllib.request.Request(
            webhook_url, data=payload,
            headers={'Content-Type': 'application/json'}
        )
        urllib.request.urlopen(req)
    except Exception as e:
        logger.error(f'Alert delivery failed: {e}')


@app.before_request
def before_request():
    g.start_time = time.time()


@app.after_request
def after_request(response):
    duration = (time.time() - g.start_time) * 1000
    logger.info(
        f"{request.method} {request.path} "
        f"→ {response.status_code} ({duration:.0f}ms)"
    )
    return response


@app.errorhandler(Exception)
def handle_exception(e):
    logger.exception('Unhandled exception')
    send_alert(f'Production error: {type(e).__name__}: {e}')
    return jsonify({'error': 'Internal server error'}), 500


@app.route('/')
def index():
    return jsonify({'status': 'healthy', 'message': 'App is running'})


@app.route('/api/data')
def get_data():
    logger.info('Processing data request')
    return jsonify({'items': [1, 2, 3]})


if __name__ == '__main__':
    port = int(os.getenv('PORT', 5000))
    logger.info(f'Starting server on 0.0.0.0:{port}')
    app.run(host='0.0.0.0', port=port)
```

## Common mistakes

- **Expecting browser-side console.log() to appear in Replit's Console tab** — undefined Fix: Client-side JavaScript logs only appear in the Preview pane's browser DevTools. Right-click the Preview, select Inspect, and open the Console tab there.
- **Not checking the deployment Logs tab after deploying, missing startup errors** — undefined Fix: Always open the Logs tab in the Deployments pane after deploying. Startup errors (missing Secrets, port binding failures) appear here within the first few seconds.
- **Using DEBUG logging level in production, flooding the Logs tab with noise** — undefined Fix: Set logging level to WARNING or INFO in production. Use DEBUG only for active troubleshooting sessions.
- **Not setting PYTHONUNBUFFERED=1, causing Python logs to appear delayed or not at all** — undefined Fix: Add PYTHONUNBUFFERED=1 to [run.env] in your .replit file. Without it, Python buffers stdout and logs may appear late or not at all in the Console.

## Best practices

- Use structured logging with timestamps and severity levels instead of plain print() or console.log()
- Log every incoming HTTP request with method, path, status code, and response time
- Set logging level to WARNING or ERROR in production to reduce noise
- Add error alerting (Slack webhook, email) since the Logs tab does not send failure notifications
- Check the deployment Logs tab after every new deployment to verify the app started correctly
- Remember that client-side console.log() only appears in Preview DevTools, not in the Console tab
- Store webhook URLs and API keys for logging services in Tools → Secrets, not in source code
- Log enough context to reproduce issues — include request parameters, user IDs, and timestamps

## Frequently asked questions

### Where do I find production logs for my deployed Replit app?

Open the Deployments pane in your workspace and click the Logs tab. This shows real-time output from your production application including all server-side print(), console.log(), and logging module output.

### What is the difference between Console and Shell output?

The Console shows output from the Run button with structured entries (command, stdout, stderr, duration). The Shell is an interactive terminal for running ad-hoc commands. They are independent — Shell output does not appear in the Console and vice versa.

### Why are my Python logs delayed or missing in the Console?

Python buffers stdout by default. Add PYTHONUNBUFFERED=1 to [run.env] in your .replit file, or pass the -u flag in your run command: run = 'python -u main.py'. This forces Python to flush output immediately.

### Can I search or filter deployment logs?

The deployment Logs tab in Replit shows a real-time stream without advanced search or filtering as of March 2026. For searchable logs, use structured logging and send output to an external service like Logtail, Papertrail, or Datadog.

### Does Replit send alerts when my deployed app crashes?

No. Replit does not send crash notifications automatically. Add error alerting to your application code using Slack webhooks, email, or a monitoring service. The send_alert function shown in this tutorial is a simple way to get started.

### How long are deployment logs retained?

Replit retains recent deployment logs but does not guarantee long-term storage. For audit requirements or historical debugging, add a logging service that retains logs for your desired retention period.

### Can Replit Agent set up logging for my app?

Yes. Ask Agent: 'Add structured logging to this Flask app with timestamps, request logging, and Slack error alerts using the SLACK_WEBHOOK_URL secret.' Agent v4 will add the logging configuration, request middleware, and alert function.

### What if I need centralized logging, monitoring, and alerting across multiple services?

For production applications that need centralized log aggregation, metric dashboards, uptime monitoring, and incident alerting, the RapidDev engineering team can integrate your Replit apps with professional observability platforms tailored to your infrastructure.

---

Source: https://www.rapidevelopers.com/replit-tutorial/how-to-monitor-real-time-logs-for-a-web-application-hosted-on-replit
© RapidDev — https://www.rapidevelopers.com/replit-tutorial/how-to-monitor-real-time-logs-for-a-web-application-hosted-on-replit
