pino-postgres is a pino transport that writes log entries to a PostgreSQL database. Version 0.0.41 is the latest stable release, last updated in 2020 with a low release cadence (no recent updates). It works as a command-line pipe transport, consuming pino NDJSON from stdin and inserting into a specified PostgreSQL table. Unlike other pino transports like pino-pretty (console output) or pino-elasticsearch (Elasticsearch), it targets PostgreSQL persistence without requiring a separate log shipper. It requires manual table creation with a jsonb column and offers configurable flush interval, buffer size, SSL support, and pass-through mode.
npm install pino-postgresNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates piping pino NDJSON logs to pino-postgres, requiring a pre-created PostgreSQL table with a jsonb column.
Run a CREATE TABLE statement manually (e.g., CREATE TABLE logs (id SERIAL PRIMARY KEY, content JSONB, created_at TIMESTAMP DEFAULT NOW()));
Consider using alternative transports like pino-pretty, pino-roll, or writing a custom transport via pino.transport().
Add --ssl to your pino-postgres command.
Set --flush-interval and --buffer-size according to your reliability needs, or use a more robust transport.
Add --column <your_column_name> to the command line.
Check the --connection string (e.g., postgres://user:pass@localhost:5432/mydb) and ensure PostgreSQL is accessible.
Create the table in advance: CREATE TABLE logs (id SERIAL PRIMARY KEY, content JSONB, created_at TIMESTAMP DEFAULT NOW());
Either rename your column to 'content' or specify the correct column with --column <name>.
Add --ssl to the command line.