官方文档:https://github.com/NarrativeScience/Log.io
需要使用root用户安装
1.安装node.js
node.js安装包获取,请搜索。
tar zxvf node-v0.12.7.tar.gz
cd node-v0.12.7
./configure
make && make install
2.安装npmwget --no-check-certificate https://npmjs.org/install.sh && sh install.sh
3.防止npm被墙,使用cnpm替代npm install -g cnpm --registry=https://registry.npm.taobao.org
4.安装log.iocnpm install -g log.io --user ‘root‘
5.服务器端和客户端的配置文件都在~/.log.io/下面
6.启动服务端nohup log.io-server &
7.配置客户端,设置日志收集来源
vi ~/.log.io/harvester.conf
exports.config = {
nodeName: "test_server_01",
logStreams: {
tomcat: [
"/home/test/local/tomcat/logs/catalina.out"
],
tomcat8030: [
"/home/test/local/tomcat8030/logs/catalina.out"
]
},
server: {
host: ‘0.0.0.0‘,
port: 28777
}
}
8.修改log.io的一处bug
vi /usr/local/lib/node_modules/log.io/lib/harvester.js
if (event === ‘change‘) {
return fs.stat(path, function(err, stat) {
var tmp_total = !err ? (stat.size || 0) : 0;
if (tmp_total > 0) {
_this._readNewLogs(path, tmp_total, currSize);
return currSize = tmp_total;
} else {
return tmp_total;
}
});
}
9.启动客户端
nohup log.io-harvester &
原文地址:http://blog.51cto.com/qiangsh/2095639
时间: 2024-11-05 18:42:36