`syslog-client` is a pure JavaScript library for Node.js, designed to send log messages to remote syslog servers. It supports both the legacy BSD Syslog Protocol (RFC 3164) and the modern Syslog Protocol (RFC 5424), offering flexibility in message formatting. The library facilitates communication over both TCP and UDP transports, providing options to configure the target host, port, facility, and severity for outgoing messages. Currently at version 1.1.1, with its last update approximately 9 years ago, the package is considered to be in maintenance status. Its key differentiators include comprehensive RFC support and a simple API for common syslog operations, though developers should be aware of its age and lack of recent updates when considering new projects.
npm install syslog-clientVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize a syslog client, send basic log messages, and specify custom options like severity and facility. It highlights the use of `createClient` and the `log` method with callbacks for error handling.
When creating the client, pass `{ rfc3164: false }` in the options object: `syslog.createClient('127.0.0.1', { rfc3164: false });`Specify the `transport` and `port` options: `syslog.createClient('127.0.0.1', { transport: syslog.Transport.Tcp, port: 6514 });`Adjust `tcpTimeout` in the client options to suit your network environment: `syslog.createClient('127.0.0.1', { transport: syslog.Transport.Tcp, tcpTimeout: 5000 });`For new projects or critical applications, consider evaluating more modern and actively maintained syslog client libraries for Node.js, such as `@resqclub/syslog-client` or `@n8n/syslog-client`, or the `winston-syslog` transport if using Winston.
Ensure the syslog server (e.g., rsyslog, syslog-ng) is running on the target machine and configured to listen on the specified port and protocol. Check firewall rules on both the client and server. For TCP, ensure the server is configured to accept TCP connections.
Use the CommonJS `require` syntax as demonstrated in the documentation: `const syslog = require('syslog-client');` and then access `syslog.createClient()`. If using TypeScript with `esModuleInterop` enabled, `import syslog from 'syslog-client';` might work, but direct named imports are generally not supported for pure CJS modules.Verify the `target` IP address and `port` in `createClient`. Confirm the `transport` (UDP/TCP) matches the server's configuration. Check the syslog server's configuration (`/etc/rsyslog.conf` or `/etc/syslog-ng/syslog-ng.conf`) for any filtering rules that might be discarding messages based on facility, severity, program name, or source host. Temporarily increase verbosity on the server or use a network packet analyzer like Wireshark/tcpdump.
No dependency data recorded yet.