使用nodejs构建web应用很是方便,可是带来的日志管理问题却不太好搞,由于通常程序日志都是写本地文件中的。固然,若是您不闲折腾使用rsyslog去作日志集中管理也是能够的,不过配置略麻烦
。今天要介绍的是一个基于nodejs开发的集中式日志管理系统。node
原本找到一个log.io的项目,可是是几年前用的,node8.6跑不起来,看了一下原理以后决定本身造一个轮子。git
实时上报最新的一行
。https://github.com/xialeistud...github
sudo npm install log.io-ts -g
log.io start-server -p 10001 -P 111111
具体选项能够log.io start-server --help
查看web
此时服务器启动成功能够接收客户端上报的日志了npm
配置文件能够随便放,启动客户端时指明绝对路径便可,本例/Users/xialei/log-config.json
json
[ {"node":"test","path":"/Users/xialei/a.txt"} ]
log.io start-client -s http://localhost:10001 -c /Users/xialei/log-config.json
http://localhost:10001?passwo... 密码为启动服务器指定的--pwd参数,默认administrator浏览器
/Users/xialei/a.txt
echo '222'>/Users/xialei/a.txt