Registry / observability / syslog-client

syslog-client

JSON →
library1.1.1jsnpmunverified

`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-client
INSTALL
IMPORT
SIG · SYSLOG-CLIENT
S
syslog-client
observabilityjavascriptv1.1.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

syslog
const syslog = require('syslog-client');
import syslog from 'syslog-client';
This package is primarily a CommonJS module. Direct ESM import might not work as expected and would require a bundler or specific Node.js loader configuration.
createClient
const client = syslog.createClient('127.0.0.1');
import { createClient } from 'syslog-client';
The `createClient` function is a property of the main `syslog` object exported via CommonJS `require`.
Transport, Facility, Severity
const transport = syslog.Transport.Udp; // Similarly for Facility and Severity
import { Transport } from 'syslog-client';
Constants like `Transport`, `Facility`, and `Severity` are nested objects under the main `syslog` export and should be accessed as `syslog.Transport.Udp`.

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.

const os = require('os'); const syslog = require('syslog-client'); const options = { syslogHostname: os.hostname(), transport: syslog.Transport.Udp, port: 514, facility: syslog.Facility.Local0, severity: syslog.Severity.Informational, rfc3164: true // Defaults to RFC 3164 }; // Create a syslog client targeting localhost via UDP const client = syslog.createClient('127.0.0.1', options); client.log('This is an example syslog message from my Node.js application.', {}, (error) => { if (error) { console.error('Failed to send syslog message:', error); } else { console.log('Syslog message sent successfully.'); } client.close(); // Close the client connection if TCP is used or to clean up resources }); // Example with custom severity client.log('An important warning occurred!', { severity: syslog.Severity.Warning, facility: syslog.Facility.User }, (error) => { if (error) console.error('Warning message failed:', error); else console.log('Warning message sent.'); });
Debug
Known issues
gotchaBy default, the client sends messages formatted according to RFC 3164. If you require the newer RFC 5424 format, you must explicitly set the `rfc3164` option to `false` in the `createClient` options object.
fix
When creating the client, pass `{ rfc3164: false }` in the options object: `syslog.createClient('127.0.0.1', { rfc3164: false });`
affects: >=1.0.0
gotchaThe package defaults to using UDP transport on port 514. If your syslog server expects TCP or a different port, these must be explicitly configured in the client options.
fix
Specify the `transport` and `port` options: `syslog.createClient('127.0.0.1', { transport: syslog.Transport.Tcp, port: 6514 });`
affects: >=1.0.0
gotchaThe `tcpTimeout` option, defaulting to 10 seconds, controls both connection attempts and TCP acknowledgement waits. This default might be too long for highly responsive systems or too short for unreliable network conditions.
fix
Adjust `tcpTimeout` in the client options to suit your network environment: `syslog.createClient('127.0.0.1', { transport: syslog.Transport.Tcp, tcpTimeout: 5000 });`
affects: >=1.0.0
gotchaThis package has not been updated in approximately 9 years. While it may still function for basic syslog needs, it might lack modern features, performance optimizations, or security patches found in more actively maintained alternatives.
fix
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.
affects: <=1.1.1
Errors
Common errors & fixes
Error: connect ECONNREFUSED
The syslog server at the specified target IP and port is not running or is blocking connections.
fix
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.
TypeError: syslog.createClient is not a function
This error typically occurs when attempting to use ESM `import { createClient } from 'syslog-client'` with a CommonJS-only module, or incorrectly destructuring the `require` output.
fix
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.
Message not appearing in syslog server logs.
This can be due to incorrect IP address, port, transport protocol, or facility/severity filtering on the syslog server.
fix
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.
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
16 hits · last 30 days
node
14
OpenAI (training)
1
Resources
syslog-client — npm install syslog-client · libregistry