Monitor app performance in Replit using the Console tab for runtime output, the deployment Logs tab for production logs, and structured logging with log levels in your code. The Console shows stdout and stderr from the Run button, while deployment logs are accessible in the Deployments pane. Add structured JSON logging to your app for searchable, filterable production logs that help you debug issues quickly.
Monitor Application Logs and Performance in Replit
When your app behaves unexpectedly, logs are your first line of defense. This tutorial shows you how to use Replit's Console for development logging, the deployment Logs tab for production monitoring, and structured logging patterns that make it easy to find and fix issues. You will set up log levels, add request logging middleware, and learn where to look when something goes wrong in both development and production environments.
Prerequisites
- A Replit account on any plan
- A Replit App with a running application (Node.js or Python)
- Basic familiarity with the Replit workspace and Console tab
- No prior logging experience required
Step-by-step guide
Understand the Console vs Shell vs deployment logs
Understand the Console vs Shell vs deployment logs
Replit has three distinct places where output appears. The Console tab shows output from the Run button — it displays structured entries with command, stdout, stderr, duration, and status metadata. The Shell is an interactive terminal for ad-hoc commands. Deployment logs appear in the Deployments pane under the Logs tab and show output from your production app. Client-side JavaScript logs (browser console.log) only appear in the Preview DevTools, not in the Console. Understanding which pane to check saves significant debugging time.
Expected result: You understand the three logging locations: Console (development), Shell (commands), and Deployments > Logs (production).
Add log levels to your application
Add log levels to your application
Instead of using console.log for everything, implement structured log levels: debug for development details, info for normal operations, warn for recoverable issues, and error for failures. Create a simple logger utility that prefixes each message with the level and timestamp. This makes it easy to filter logs by severity and find the important messages quickly.
1// src/utils/logger.js2const LOG_LEVELS = { debug: 0, info: 1, warn: 2, error: 3 };3const CURRENT_LEVEL = LOG_LEVELS[process.env.LOG_LEVEL || 'info'];45function log(level, message, data = {}) {6 if (LOG_LEVELS[level] < CURRENT_LEVEL) return;7 const entry = {8 timestamp: new Date().toISOString(),9 level: level.toUpperCase(),10 message,11 ...data,12 };13 const output = JSON.stringify(entry);14 if (level === 'error') console.error(output);15 else if (level === 'warn') console.warn(output);16 else console.log(output);17}1819module.exports = {20 debug: (msg, data) => log('debug', msg, data),21 info: (msg, data) => log('info', msg, data),22 warn: (msg, data) => log('warn', msg, data),23 error: (msg, data) => log('error', msg, data),24};Expected result: Your app outputs structured JSON log entries with timestamps and levels. Debug messages only appear when LOG_LEVEL is set to debug.
Add request logging middleware
Add request logging middleware
For web applications, logging every incoming HTTP request helps you understand traffic patterns and identify slow endpoints. Add middleware that logs the method, path, status code, and response time for each request. This is the most valuable logging you can add to a web app — it gives you a complete picture of what your server is doing.
1// src/middleware/requestLogger.js2const logger = require('../utils/logger');34function requestLogger(req, res, next) {5 const start = Date.now();6 7 res.on('finish', () => {8 const duration = Date.now() - start;9 const logData = {10 method: req.method,11 path: req.originalUrl,12 status: res.statusCode,13 duration_ms: duration,14 ip: req.ip,15 };16 17 if (res.statusCode >= 500) {18 logger.error('Server error', logData);19 } else if (res.statusCode >= 400) {20 logger.warn('Client error', logData);21 } else {22 logger.info('Request completed', logData);23 }24 });25 26 next();27}2829module.exports = requestLogger;Expected result: Every HTTP request generates a structured log entry with method, path, status, and response time. Errors are logged at the error level.
Wire the logger into your Express app
Wire the logger into your Express app
Import the logger and request logging middleware into your main application file. The request logger middleware should be added early in the middleware chain so it captures all requests. Use the logger throughout your application to replace raw console.log statements with structured, leveled output.
1// index.js2const express = require('express');3const logger = require('./src/utils/logger');4const requestLogger = require('./src/middleware/requestLogger');56const app = express();7const PORT = process.env.PORT || 3000;89// Add request logging middleware10app.use(requestLogger);11app.use(express.json());1213app.get('/health', (req, res) => {14 res.json({ status: 'ok' });15});1617app.get('/api/data', (req, res) => {18 logger.info('Fetching data', { userId: req.query.userId });19 // ... fetch data ...20 res.json({ data: [] });21});2223app.listen(PORT, '0.0.0.0', () => {24 logger.info('Server started', { port: PORT, env: process.env.NODE_ENV });25});Expected result: The Console shows structured JSON log entries for every request. Server startup, data fetches, and errors are all logged with appropriate levels.
Configure log levels for development vs production
Configure log levels for development vs production
Use the [run.env] section in .replit to set LOG_LEVEL=debug during development so you see all log output. For production deployments, set LOG_LEVEL=info or LOG_LEVEL=warn in the Deployments pane under Settings to reduce log volume and focus on important events. The REPLIT_DEPLOYMENT environment variable (set to '1' in production) can also be used to detect the environment automatically.
1# .replit file2run = "node index.js"34[run.env]5LOG_LEVEL = "debug"6NODE_ENV = "development"Expected result: Development Console shows all log levels including debug. Production deployment logs show only info, warn, and error messages.
Check deployment logs in the Deployments pane
Check deployment logs in the Deployments pane
After deploying your app, monitor production logs by opening the Deployments pane from the left sidebar and clicking the Logs tab. These logs show real-time output from your deployed application, including startup messages, request logs, warnings, and errors. The logs update in real time as traffic hits your deployed app. This is where you investigate production issues — check for error-level entries, slow request durations, and unexpected status codes.
Expected result: The Deployments > Logs tab shows real-time output from your production app with structured log entries for every request and event.
Complete working example
1/**2 * Structured logger with levels and JSON output3 * 4 * Usage:5 * const logger = require('./utils/logger');6 * logger.info('User logged in', { userId: '123' });7 * logger.error('Database connection failed', { error: err.message });8 * 9 * Environment:10 * LOG_LEVEL = debug | info | warn | error (default: info)11 */1213const LOG_LEVELS = {14 debug: 0,15 info: 1,16 warn: 2,17 error: 3,18};1920const CURRENT_LEVEL = LOG_LEVELS[process.env.LOG_LEVEL || 'info'];21const APP_NAME = process.env.REPL_SLUG || 'app';2223function log(level, message, data = {}) {24 if (LOG_LEVELS[level] < CURRENT_LEVEL) return;2526 const entry = {27 timestamp: new Date().toISOString(),28 level: level.toUpperCase(),29 app: APP_NAME,30 message,31 ...data,32 };3334 const output = JSON.stringify(entry);3536 switch (level) {37 case 'error':38 console.error(output);39 break;40 case 'warn':41 console.warn(output);42 break;43 default:44 console.log(output);45 }46}4748module.exports = {49 debug: (msg, data) => log('debug', msg, data),50 info: (msg, data) => log('info', msg, data),51 warn: (msg, data) => log('warn', msg, data),52 error: (msg, data) => log('error', msg, data),53};Common mistakes when monitoring app logs in Replit
Why it's a problem: Looking for client-side JavaScript logs in the Console tab
How to avoid: Client-side console.log output only appears in the Preview pane's DevTools (right-click > Inspect). The Console tab shows server-side output only.
Why it's a problem: Using console.log everywhere without log levels, making it impossible to filter important messages
How to avoid: Create a structured logger with debug, info, warn, and error levels. Control verbosity with the LOG_LEVEL environment variable.
Why it's a problem: Binding the server to 'localhost' or '127.0.0.1' instead of '0.0.0.0'
How to avoid: Always use app.listen(PORT, '0.0.0.0'). Binding to localhost prevents Replit's preview and deployment system from reaching your server.
Why it's a problem: Not checking deployment logs when the app works in development but fails in production
How to avoid: Open the Deployments pane and check the Logs tab. Production errors often stem from missing secrets or environment variables not added to the deployment configuration.
Best practices
- Replace raw console.log statements with structured logger calls that include log levels and timestamps
- Use JSON format for log entries so they are machine-parseable and searchable
- Add request logging middleware to capture method, path, status, and response duration for every HTTP request
- Set LOG_LEVEL=debug in development and LOG_LEVEL=info or higher in production
- Always bind your server to '0.0.0.0', not 'localhost', so Replit can access it
- Check the Console tab for development logs and the Deployments > Logs tab for production logs
- Include contextual data (userId, requestId, endpoint) in log entries to make debugging easier
- Log at the error level for failures and the warn level for recoverable issues
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I'm running an Express app in Replit and need structured logging with log levels and request tracking. How do I set up a logger utility that outputs JSON entries with timestamps, and add middleware that logs every HTTP request with method, path, status, and response time?
Add structured logging to this Express project. Create a logger utility in src/utils/logger.js with debug, info, warn, and error levels that outputs JSON. Create request logging middleware in src/middleware/requestLogger.js. Wire both into the main app. Set LOG_LEVEL=debug in .replit [run.env].
Frequently asked questions
Development logs appear in the Console tab when you press Run. Production logs appear in the Deployments pane under the Logs tab. Client-side browser logs only appear in the Preview pane's DevTools.
The Console shows structured output from the Run button, including stdout, stderr, and execution metadata. The Shell is an interactive Linux terminal for running ad-hoc commands. Use Run/Console for your app; use Shell for package management, Git, and diagnostics.
Set the LOG_LEVEL environment variable to 'warn' or 'error' in the Deployments pane under Settings. This suppresses debug and info messages, showing only warnings and errors.
Yes. Open the Deployments pane and click the Logs tab. Logs update in real time as your deployed app processes requests and events.
Replit does not have built-in integrations with external logging services, but you can send logs to any HTTP endpoint from your code. Use fetch() to POST log entries to Datadog, LogRocket, or any other service that accepts webhook data.
Check two things: (1) the LOG_LEVEL environment variable may be set to a higher level in production, filtering out info and debug messages. (2) Make sure you are checking the Deployments > Logs tab, not the Console tab.
Yes. Prompt Agent v4: 'Add structured JSON logging with log levels to this Express app. Create a logger utility and request logging middleware. Set LOG_LEVEL=debug for development.' Agent will create the files and wire them into your application.
For production applications that need performance dashboards, error tracking, and alerting, consider integrating with services like Sentry for error tracking or UptimeRobot for uptime monitoring. The RapidDev team can help set up professional observability for your Replit deployments.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation