The `nsyslog-parser` library provides a robust and flexible solution for parsing syslog messages in Node.js. It supports widely used syslog formats including RFC 3164 (BSD), RFC 5424 (IETF), and the Common Event Format (CEF) popularized by ArcSight. A key differentiator is its fault-tolerant parsing mechanism, designed to extract as much information as possible from non-standard, erroneous, or malformed messages without throwing errors, making it suitable for environments with diverse and potentially imperfect log sources. As of version 0.10.1, the package is primarily a CommonJS module, offering a single default export as a parser function. While specific release cadence is not explicitly stated, its sub-1.0 version suggests a mature but stable utility for its core parsing functionality.
npm install nsyslog-parserVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to import and use the `nsyslog-parser` function to parse various syslog message formats, including BSD, IETF RFC 5424, and CEF. It shows how the parser handles different log line structures and the resulting structured output.
Always inspect the parsed output for expected fields and values, especially when dealing with potentially unreliable log sources, to ensure data integrity and completeness.
Pin the exact version in your `package.json` (`"nsyslog-parser": "0.10.1"`) or use a tilde `~` for patch updates only (`"nsyslog-parser": "~0.10.1"`), and thoroughly test your application after any upgrade.
Create a `declarations.d.ts` file with `declare module 'nsyslog-parser';` or define specific types for the expected parsed output if strict typing is required.
Use `import parser from 'nsyslog-parser';` for ESM, or `const parser = require('nsyslog-parser');` for CommonJS.Switch to ESM import syntax: `import parser from 'nsyslog-parser';`.
Inspect the `originalMessage` field in the parsed output and compare it against the expected RFC or CEF format to identify discrepancies. Adjust the log source if possible, or implement custom post-parsing logic to handle specific malformations.
No dependency data recorded yet.