2011-09-29 188 views
10

我刚刚npm install node-syslog,但它不起作用。需要关于SysLog和Node.js的建议

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

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

哦..如果有一个很好的syslog解析器(node.js),请让我知道。 :)

回答

10

我用两个

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

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

没有任何问题。

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

npm search $(what im looking for) 

我跑NPM搜索系统日志,这是我的输出,希望它帮助。

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 
1

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

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

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

4

我尝试了npm搜索中列出的大多数模块,并且对它们中的任何一个都没有多少运气。

幸运的是,最终,我碰到rconsole我发现更容易配置比任何其他人使用跌跌撞撞。

它也很好,它允许你在开发过程中对你的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

3

syslog-stream我的系统日志使用本地C绑定日志创建一个可写流。它还包括测试。

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

12

和你一样,我也寻找系统日志解决方案,直到我发现了这个观点:

日志是一个流,它理应每个人都这样对待他们。 你的方案应该记录到标准输出和/或标准错误和遗漏任何企图 处理日志路径,登录旋转,或通过系统日志 协议发送日志。导演在节目的日志流那张可以留给 到运行容器:本地终端或IDE(开发 环境),一个暴发户/ Systemd启动脚本(在传统 主机环境),或类似Logplex/Heroku的系统(在平台 环境中)。

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

现在我高兴地总结我的搜索和正在使用console.log

+1

我非常赞成这种办法的! –

+1

它们更像是比流可靠的有序数据报。日志框架的优点是它们保留日志消息边界。 (考虑其中有回溯或JSON对象的日志)。 – alanfalloon