在 Debian 上监控 JS(Node.js / 前端构建 / 浏览器)日志,常见做法取决于日志类型和运行环境。下面按场景给你一套实用方案。
tail -f /path/to/app.log
或 PM2 日志:
pm2 logs
如果你用 systemd 启动 Node:
journalctl -u yourapp.service -f
日志位置:
/var/log/syslog
journalctl
apt install inotify-tools
inotifywait -m /var/log/js/app.log
apt install swatch
swatch --watch /var/log/js/app.log --tail
npm install winston
示例:
const winston = require('winston');
winston.add(new winston.transports.File({ filename: 'app.log' }));
pm2 install pm2-logrotate
apt install promtail loki
适合容器和 JS 服务
如果是前端 JS:
window.onerror✅ Node + PM2
✅ Winston 写日志
✅ journalctl / pm2 logs
✅ Loki + Grafana 或 Sentry
如果你能告诉我:
我可以给你更精确的监控方案或配置文件。