需要关于使用Node.js的SysLog的build议

我只是npm安装node-syslog,但它不起作用。

我有一个系统日志服务器(IP地址和local0)。

我正在寻找一个系统日志模块来帮助我发送消息到系统日志。 但是我不知道应该用哪一个。 请给我一些build议。 谢谢。

哦,如果有一个很好的syslogparsing器(node.js),请让我知道。 🙂

我用过两个

https://github.com/cloudhead/node-syslog

https://github.com/cconstantine/syslog-node

没有任何问题。

但是,当我在你的情况下运行:

npm search $(what im looking for) 

我运行npmsearch系统日志,这是我的输出,希望它有帮助。

 ain Syslog logging for node.js =akaspin (prehi ain-tcp Syslog logging for node.js, with syslog/TCP support =andry1 2011-0 ain2 Syslog logging for node.js. Continuation of ain =phuesler 2012-0 ain2-fs Syslog logging for node.js. Continuation of ain =ossareh 2011-1 ain2-papandreou Syslog logging for node.js. Continuation of ain =papandreou 2012-0 artifi-glossy Syslog parser and producer. It is fork of https://github.com/squeeks/glossy - pleas beatit Simple agent that can stay hooked on a log file (even if while log rotated and send frontail tail -F output in browser =mthenw 2012-0 glossy Syslog parser and producer =squeeks 2012-0 netasqsyslog Syslog for NETASQ security appliances =sdolard 2012-0 node-nativesyslog JavaScript-only syslog module for NodeJS =janoszen 2011-1 node-syslog Node module to support sending messages to syslog daemon =schamane 2012-0 posix The missing POSIX system calls =mel 2012-0 rconsole 'syslog.h' bindings with a revised console module =tblobaum 2012-0 simplelogger A simple logging solution supporting file, stdout and syslog output =ditesh 2011-06 splog A NodeJS library which provides a syslog-like remote logging interface =mattbornski syslog Syslog-ng TCP client, with basic fault-tolerance. =cloudhead 2011-0 syslog-node A syslog server and realtime web view of syslog messages =cconstantine 2011-0 syslogd-nodejs syslogd in node.js with logging to cli, file, mongodb and via websockets =crahles 2 tails Aggregate your syslog messages & filter for those that matter in real time. =porter winston-syslog A syslog transport for winston =indexzero 2011-0 winston-syslog-ain2 An ain2 based syslog transport for winston =lamtha 2012-0 

像你一样,我也在寻找一个系统日志解决scheme,直到我发现这个观点:

日志是一个stream,而且每个人都应该这样对待它们。 您的程序应该logging到标准输出和/或标准错误,并忽略任何尝试处理日志path,logging轮转或通过系统日志协议发送日志。 指导程序日志stream的位置可以放在运行时容器中:本地terminal或IDE(在开发环境中),Upstart / Systemd启动脚本(在传统的宿主环境中),或者像Logplex / Heroku这样的系统平台环境)。

http://adam.heroku.com/past/2011/4/1/logs_are_streams_not_files/

现在我已经愉快地结束了我的search,并使用console.log

我尝试了npmsearch中列出的大多数模块,并且对它们中的任何一个都没有什么好运气。

幸运的是,最后我偶然发现了我发现的rconsole比其他设备更容易configuration和使用。

这也很好,它允许你在开发过程中对你的stdout进行颜色和时间戳(和跟踪等)。

要使用,只需npm i rconsole ,然后从文档:

 require('rconsole') console.set({ facility: 'local0', title: 'basic' }) console.emerg('level 0') console.alert('level 1') console.crit('level 2') console.error('level 3') console.warn('level 4') console.notice('level 5') console.info('level 6') console.log('level 6') 

在OSX上,我使用tail -f /var/log/system.log来检查我的系统日志

syslog-stream使用本地C绑定为syslog创build一个可写的Stream。 它还包括testing。

然后,您可以直接写入该stream或作为另一个日志logging模块的输出。

看起来社区在这里并没有达成共识。 我遇到的每个节点系统日志项目都有很长时间的问题,看起来相当重要(或者是鬼城)。

温斯顿似乎是通用日志的最佳select,并具有可用的winston-syslog传输。 问题是,它似乎有一些相当重要的问题: https : //github.com/indexzero/winston-syslog/issues

我想我会给winston-syslog-ain2一枪,我自己。