需要使用 Node.js 进行 SysLog 的建议

发布于 2024-12-07 20:45:46 字数 185 浏览 0 评论 0原文

我刚刚 npm install node-syslog 但它不起作用。

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

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

哦..如果有一个好的系统日志解析器(node.js),也请告诉我。 :)

I have just 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. :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

后知后觉 2024-12-14 20:45:47

syslog-stream 使用本机 C 绑定为 syslog 创建可写流。它还包括测试。

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

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.

秋千易 2024-12-14 20:45:47

社区似乎尚未就此达成共识。我遇到的每个节点系统日志项目都有长期悬而未决的问题,这些问题似乎非常重要(或者是鬼城)。

Winston 似乎是通用日志记录的最佳选择,并且具有可用的 Winston-syslog 传输。问题是它似乎存在一些非常重要的问题: https://github.com/ indexzero/winston-syslog/issues

我想我要亲自尝试一下winston-syslog-ain2。

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.

情域 2024-12-14 20:45:46

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

日志是一种流,每个人都应该这样对待它。
您的程序应该记录到 stdout 和/或 stderr 并忽略任何尝试
处理日志路径、日志轮换或通过 syslog 发送日志
协议。引导程序日志流的去向可以保留
到运行时容器:本地终端或 IDE(正在开发中)
环境),Upstart / Systemd 启动脚本(传统的
托管环境),或者像 Logplex/Heroku 这样的系统(在一个平台中)
环境)。

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

现在我很高兴地结束了我的搜索并正在使用 console.log

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.

掩于岁月 2024-12-14 20:45:46

我都用过

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

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

没有任何问题。

但是当我处于你的情况时,我运行:

 npm search $(what im looking for)

我运行了 npm search syslog ,这是我的输出,希望它有所帮助。

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'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
ι不睡觉的鱼゛ 2024-12-14 20:45:46

我尝试了 npm 搜索中列出的大部分模块,但对其中任何一个都没有什么运气。

幸运的是,最后我偶然发现了 rconsole 我发现它更容易使用配置和使用比任何其他人都要好。

它也很好,它允许您在开发过程中对标准输出进行着色和时间戳(以及跟踪等)。

要使用,只需 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 检查我的系统日志

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文