
View and Manage Node.js Logs from cPanel File Manager
View and Manage Node.js Logs from cPanel File Manager
Why Monitor Node.js Logs?
Logs provide valuable insights into your application’s performance, errors, and user activity. Regularly checking your logs helps you quickly identify and fix issues.
Prerequisites
- Node.js application hosted on cPanel (Hiverift or similar)
- Access to your cPanel dashboard
- Basic familiarity with Node.js app structure
Step 1: Log into cPanel
Open your web browser and navigate to https://yourdomain.com/cpanel
. Enter your cPanel username and password to log in.
Step 2: Locate Your Node.js Application Directory
In the cPanel dashboard, open File Manager. Navigate to the folder where your Node.js app files reside. This is usually inside the home/username
directory or a subfolder like nodejsapp
.
Step 3: Find Your Log Files
Node.js apps typically generate logs in these common ways:
- Custom Log Files: Defined in your app code using
console.log()
or logging libraries likewinston
, saved to a file likeapp.log
orerror.log
. - Default Error Logs: cPanel may store error logs for your app, often accessible via Errors or Raw Access Logs in cPanel.
Step 4: Open and View Log Files
- In File Manager, locate your log files, for example,
logs/app.log
orlogs/error.log
. - Select the log file and click View or Edit to open it in the built-in text editor.
- Review the logs for errors, warnings, or info messages.
Step 5: Manage Your Logs
- Download: To keep a backup, right-click the log file and select Download.
- Clear Logs: To free up space, open the log file in edit mode, delete the contents, and save the empty file.
- Rotate Logs: For large apps, implement log rotation in your Node.js app or via cron jobs to archive logs periodically.
Step 6: Use cPanel’s Error Logs for Quick Troubleshooting
Besides custom logs, you can also check:
- Errors Section: In cPanel, click on Errors to see recent server and app errors.
- Raw Access Logs: Provides detailed access logs useful for debugging traffic and request issues.
Example: Simple File Logging in Node.js
const fs = require('fs');
const logStream = fs.createWriteStream('./logs/app.log', { flags: 'a' });
function log(message) {
const timestamp = new Date().toISOString();
logStream.write(`[${timestamp}] ${message}\n`);
}
// Usage
log('Server started successfully');
log('Received a request on /api/data');
Summary
Using cPanel’s File Manager to view and manage your Node.js logs is a simple yet powerful way to keep your applications healthy and responsive. Regular log monitoring combined with effective log management practices ensures your app runs smoothly.
For more help, contact dev@hiverift.com.
© 2025 Hiverift. All rights reserved.