开发者

Need suggestion for SysLog with Node.js

I have jus开发者_开发问答t npm install node-syslog but it doesn't work.

I have a syslog server (IP address , and local0).

And I'm looking for a syslog module to help me post the message to syslog. But I don't know which one I should use. Please give me some suggestion. thanks.

oh.. if there is a good syslog parser (node.js), please let me know too. :)


Like you, I was also searching for a syslog solution until I found this opinion:

Logs are a stream, and it behooves everyone to treat them as such. Your programs should log to stdout and/or stderr and omit any attempt to handle log paths, log rotation, or sending logs over the syslog protocol. Directing where the program’s log stream goes can be left up to the runtime container: a local terminal or IDE (in development environments), an Upstart / Systemd launch script (in traditional hosting environments), or a system like Logplex/Heroku (in a platform environment).

https://adam.herokuapp.com/past/2011/4/1/logs_are_streams_not_files/

Now I've happily concluded my search and am using console.log.


I've used both

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

and

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

without any issues.

But when I'm in your situation I run:

 npm search $(what im looking for)

I ran npm search syslog and this is my output, hope it helps.

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


I tried most of the modules listed in npm search, and had very little luck with any of them.

Luckily in the end, I stumbled across rconsole which I found was MUCH easier to configure and use than any of the others.

It's also nice that it allows you to colour and timestamp (and trace, etc) your stdout during development.

To use, simply npm i rconsole, then, from the docs:

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')

On OSX, I check my syslog using tail -f /var/log/system.log


It doesn't look like the community has come to a consensus here. Each of the node syslog projects I've come across have long-open issues that seem pretty significant (or are ghost towns).

Winston seems to be the best option for general-purpose logging and has the winston-syslog transport available. The problem is that there seem to be some pretty significant issues with it: https://github.com/indexzero/winston-syslog/issues

I think I'm going to give winston-syslog-ain2 a shot, myself.


syslog-stream creates a writable Stream for syslog using native C bindings. It also includes tests.

You could then write to that stream directly or as an output for another logging module.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜