在 Linux 上查看 JS(JavaScript)日志,取决于日志是从哪里产生的。下面按常见场景给你说明:
Linux 本身看不到浏览器里的 console.log,需要通过浏览器或远程调试。
F12 → Console 查看日志前端日志只能通过:
✅ 前端日志不在 Linux 文件里
node app.js
日志直接打印在终端
nohup node app.js > app.log 2>&1 &
tail -f app.log
pm2 logs
pm2 logs app
# 实时查看
tail -f xxx.log
# 查看最后100行
tail -n 100 xxx.log
# 搜索关键字
grep "error" xxx.log
# 动态搜索
tail -f xxx.log | grep error
tail -f /var/log/nginx/access.log
tail -f /var/log/nginx/error.log
docker logs -f 容器名
docker logs -f --tail 100 容器名
console.log 是否被禁用ps -ef | grep node如果你能告诉我:
我可以给你更精确的命令。